Created
October 9, 2016 20:39
-
-
Save twizmwazin/9b4a1c0ab21008e7fd3dadc0ac6fe10a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.lang.StringBuilder; | |
| class BuilderTest { | |
| public static void main(String args[]) { | |
| long start = System.currentTimeMillis(); | |
| for (int i = 0; i < 100000; ++i) { | |
| StringBuilder b = new StringBuilder(); | |
| b.append("1"); | |
| b.append("2"); | |
| b.append("3"); | |
| b.append("4"); | |
| b.append("5"); | |
| b.append("6"); | |
| b.append("7"); | |
| b.append("8"); | |
| b.append("9"); | |
| String n = b.toString(); | |
| } | |
| System.out.println("Finished in " + (System.currentTimeMillis() - start)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StringTest { | |
| public static void main(String args[]) { | |
| long start = System.currentTimeMillis(); | |
| for (int i = 0; i < 100000; ++i) { | |
| String n = ""; | |
| n += "1"; | |
| n += "2"; | |
| n += "3"; | |
| n += "4"; | |
| n += "5"; | |
| n += "6"; | |
| n += "7"; | |
| n += "8"; | |
| n += "9"; | |
| } | |
| System.out.println("Finished in " + (System.currentTimeMillis() - start)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment