Skip to content

Instantly share code, notes, and snippets.

@avafloww
Created February 5, 2014 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avafloww/8834021 to your computer and use it in GitHub Desktop.
Save avafloww/8834021 to your computer and use it in GitHub Desktop.
HashMap/ConcurrentHashMap Performance Comparison
Testing HashMap with 100 objects...
.containsKey() - 6418 ns / 0.006418 ms
.get() - 10793 ns / 0.010793 ms
.put() - 9043 ns / 0.009043 ms
.remove() - 8751 ns / 0.008751 ms
Testing ConcurrentHashMap with 100 objects...
.containsKey() - 2625 ns / 0.002625 ms
.get() - 2334 ns / 0.002334 ms
.put() - 4667 ns / 0.004667 ms
.remove() - 15460 ns / 0.015460 ms
-------------------------------------------
Testing HashMap with 500 objects...
.containsKey() - 2042 ns / 0.002042 ms
.get() - 2042 ns / 0.002042 ms
.put() - 2334 ns / 0.002334 ms
.remove() - 2626 ns / 0.002626 ms
Testing ConcurrentHashMap with 500 objects...
.containsKey() - 2042 ns / 0.002042 ms
.get() - 2334 ns / 0.002334 ms
.put() - 4376 ns / 0.004376 ms
.remove() - 4376 ns / 0.004376 ms
-------------------------------------------
Testing HashMap with 1000 objects...
.containsKey() - 1751 ns / 0.001751 ms
.get() - 1751 ns / 0.001751 ms
.put() - 2042 ns / 0.002042 ms
.remove() - 2042 ns / 0.002042 ms
Testing ConcurrentHashMap with 1000 objects...
.containsKey() - 2042 ns / 0.002042 ms
.get() - 2042 ns / 0.002042 ms
.put() - 4959 ns / 0.004959 ms
.remove() - 4376 ns / 0.004376 ms
-------------------------------------------
Testing HashMap with 5000 objects...
.containsKey() - 2042 ns / 0.002042 ms
.get() - 2626 ns / 0.002626 ms
.put() - 1751 ns / 0.001751 ms
.remove() - 2334 ns / 0.002334 ms
Testing ConcurrentHashMap with 5000 objects...
.containsKey() - 2918 ns / 0.002918 ms
.get() - 2334 ns / 0.002334 ms
.put() - 4668 ns / 0.004668 ms
.remove() - 4667 ns / 0.004667 ms
-------------------------------------------
Testing HashMap with 10000 objects...
.containsKey() - 2333 ns / 0.002333 ms
.get() - 1750 ns / 0.001750 ms
.put() - 583 ns / 0.000583 ms
.remove() - 2042 ns / 0.002042 ms
Testing ConcurrentHashMap with 10000 objects...
.containsKey() - 2625 ns / 0.002625 ms
.get() - 1750 ns / 0.001750 ms
.put() - 583 ns / 0.000583 ms
.remove() - 9918 ns / 0.009918 ms
-------------------------------------------
Testing HashMap with 100000 objects...
.containsKey() - 4667 ns / 0.004667 ms
.get() - 2042 ns / 0.002042 ms
.put() - 875 ns / 0.000875 ms
.remove() - 2334 ns / 0.002334 ms
Testing ConcurrentHashMap with 100000 objects...
.containsKey() - 6709 ns / 0.006709 ms
.get() - 2625 ns / 0.002625 ms
.put() - 1166 ns / 0.001166 ms
.remove() - 8752 ns / 0.008752 ms
-------------------------------------------
Testing HashMap with 1000000 objects...
.containsKey() - 5543 ns / 0.005543 ms
.get() - 2041 ns / 0.002041 ms
.put() - 875 ns / 0.000875 ms
.remove() - 2626 ns / 0.002626 ms
Testing ConcurrentHashMap with 1000000 objects...
.containsKey() - 6709 ns / 0.006709 ms
.get() - 2333 ns / 0.002333 ms
.put() - 1167 ns / 0.001167 ms
.remove() - 8751 ns / 0.008751 ms
-------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment