Created
December 10, 2011 18:36
-
-
Save daliborfilus/1455895 to your computer and use it in GitHub Desktop.
hashtable/hashmap java benchmark
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
package benchmarks; | |
import java.util.Hashtable; | |
//import java.util.Map; | |
//import java.util.HashMap; | |
class Hash { | |
public static void main(String[] args) { | |
Integer i = new Integer(0); | |
//int i = 0; | |
Hashtable h = new Hashtable(); | |
//Map<Integer, String> h = new HashMap<Integer, String>(); | |
System.out.println("Running.."); | |
i = 0; | |
while(i < 10000000) | |
{ | |
//h.put(i, "aaa" + i); | |
h.put(i, "aaa" + i.toString()); | |
if(i < 100) | |
{ | |
// System.out.println(String.format("aaa%d", i)); | |
System.out.printf("aaa%d\n", i); | |
} | |
i += 1; | |
} | |
} | |
} | |
// int, hashmap, server = 7,3s | |
// Integer, hashmap, server = 13,8s | |
// Integer, hashmap, server, explicit toString = 14,0 | |
// int, hashtable, server = 8,1s | |
// Integer, hashtable, server = 15,6s | |
// Integer, hashtable, server, explicit toString = 15,1s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment