Created
December 30, 2011 04:51
-
-
Save ryantenney/1537951 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.util.*; | |
| import java.lang.*; | |
| class Main { | |
| public static void main (String[] args) throws java.lang.Exception { | |
| int size = 65536; | |
| Map m; | |
| long starttime, endtime; | |
| m = new HashMap(); | |
| starttime = System.currentTimeMillis(); | |
| for (int i = 0; size > i; ++i) { | |
| m.put(new NObject(), true); | |
| } | |
| endtime = System.currentTimeMillis(); | |
| System.out.printf("Inserting %d evil elements took %d ms\n", size, endtime - starttime); | |
| m = new HashMap(); | |
| starttime = System.currentTimeMillis(); | |
| for (int i = 0; size > i; ++i) { | |
| m.put(new Object(), true); | |
| } | |
| endtime = System.currentTimeMillis(); | |
| System.out.printf("Inserting %d good elements took %d ms\n", size, endtime - starttime); | |
| } | |
| public static class NObject { | |
| @Override public int hashCode() { return 1; } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment