You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains JMH (Java Microbenchmark Harness) benchmarks comparing the performance of standard Java collections from java.util with their optimized equivalents (fastutil, agrona, eclipse-collections, HPPC).
Operations benchmarked:
Sets: add, contains (hit/miss), remove, iterate, addAll, removeIf, clear. For HPPC, removeAll is used as the equivalent of removeIf.
Lists: add, get, contains (hit/miss), indexOf (hit/miss), set, insertions and deletions at the beginning and middle, remove at the end, iterate, sort, clear. Note that sorting does not exist for Agrona's IntArrayList.
Maps: put, get (hit/miss), containsKey (hit/miss), putExisting, putAll, remove, iterate over keys, values and entries, clear.
Absent lookups (miss cases) use out-of-range values that are never present in the collections. List linear searches use at most 1,024 queries per invocation, spread over the entire range of values. The sort benchmarks use a deterministic Fisher–Yates permutation of the data, prepared outside the timed region so that both implementations sort the exact same input. Agrona collections are sized with a capacity of ceil(size / 0.65) to match their default 0.65 load factor.
To run the benchmarks directly from IntelliJ, you need to install the JMH Java Microbenchmark Harness plugin.
BenchmarkRunner uses the same profile: 2 warm-up iterations of 100 ms, 5 measurement iterations of 100 ms, and 2 forks.
Results
The benchmark campaign was run on JDK 25.0.4 with 2 forks, 2 warm-up iterations of 100 ms and 5 measurement iterations of 100 ms. The complete raw results are available in results/benchmark-results-runner.json.
fastutil
HashSet vs IntOpenHashSet
The tables below present the benchmark results comparing java.util.HashSet<Integer> and it.unimi.dsi.fastutil.ints.IntOpenHashSet for the add, contains (hit/miss), remove, iterate, addAll, removeIf and clear operations.
Operation add
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.537 ± 0.074
0.165 ± 0.037
~3.25x
1000
5.172 ± 0.835
1.201 ± 0.133
~4.31x
10,000
51.233 ± 9.328
15.162 ± 2.416
~3.38x
100,000
551.373 ± 206.031
332.315 ± 30.125
~1.66x
Operation contains (hit)
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.201 ± 0.118
0.110 ± 0.044
~1.82x
1000
1.924 ± 0.307
0.707 ± 0.015
~2.72x
10,000
20.970 ± 3.224
9.942 ± 1.436
~2.11x
100,000
240.387 ± 52.372
262.672 ± 7.772
~0.92x
Operation contains (miss)
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.198 ± 0.023
0.122 ± 0.044
~1.63x
1000
1.565 ± 0.213
1.360 ± 0.015
~1.15x
10,000
18.677 ± 4.336
26.685 ± 7.453
~0.70x
100,000
151.512 ± 38.555
611.469 ± 12.274
~0.25x
Operation remove
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.160 ± 0.011
0.282 ± 0.232
~0.57x
1000
2.773 ± 0.247
1.648 ± 0.012
~1.68x
10,000
30.619 ± 3.603
30.504 ± 4.261
~1.00x
100,000
358.366 ± 79.366
603.242 ± 30.310
~0.59x
Operation iterate
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.357 ± 0.024
0.068 ± 0.017
~5.24x
1000
2.866 ± 0.032
0.378 ± 0.009
~7.57x
10,000
25.354 ± 0.295
5.432 ± 0.942
~4.67x
100,000
407.871 ± 84.826
582.265 ± 10.950
~0.70x
Operation addAll
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.823 ± 0.089
0.277 ± 0.085
~2.98x
1000
7.094 ± 0.324
2.140 ± 0.100
~3.32x
10,000
70.642 ± 7.186
20.709 ± 6.144
~3.41x
100,000
902.064 ± 132.339
1039.485 ± 39.223
~0.87x
Operation removeIf
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.425 ± 0.019
0.199 ± 0.052
~2.13x
1000
4.359 ± 0.161
1.848 ± 0.035
~2.36x
10,000
35.373 ± 0.729
61.304 ± 3.400
~0.58x
100,000
497.522 ± 19.408
912.240 ± 17.703
~0.55x
Operation clear
Size
java.util.HashSet (µs/op)
fastutil.IntOpenHashSet (µs/op)
Gain (ratio)
100
0.080 ± 0.005
0.024 ± 0.005
~3.28x
1000
0.514 ± 0.024
0.089 ± 0.011
~5.74x
10,000
3.744 ± 0.077
0.964 ± 0.218
~3.89x
100,000
58.023 ± 1.695
23.772 ± 4.151
~2.44x
Observations
add: fastutil.IntOpenHashSet is 1.66x to 4.31x faster at all sizes, with the largest gain at 1,000 elements.
contains (hit): Mixed results; fastutil.IntOpenHashSet is faster at 100, 1,000, 10,000 (up to 2.72x) and java.util.HashSet is faster at 100,000 (up to 1.09x).
contains (miss): Mixed results; fastutil.IntOpenHashSet is faster at 100, 1,000 (up to 1.63x) and java.util.HashSet is faster at 10,000, 100,000 (up to 4.04x).
remove: Mixed results; fastutil.IntOpenHashSet is faster at 1,000, 10,000 (up to 1.68x) and java.util.HashSet is faster at 100, 100,000 (up to 1.76x).
iterate: Mixed results; fastutil.IntOpenHashSet is faster at 100, 1,000, 10,000 (up to 7.57x) and java.util.HashSet is faster at 100,000 (up to 1.43x).
addAll: Mixed results; fastutil.IntOpenHashSet is faster at 100, 1,000, 10,000 (up to 3.41x) and java.util.HashSet is faster at 100,000 (up to 1.15x).
removeIf: Mixed results; fastutil.IntOpenHashSet is faster at 100, 1,000 (up to 2.36x) and java.util.HashSet is faster at 10,000, 100,000 (up to 1.83x).
clear: fastutil.IntOpenHashSet is 2.44x to 5.74x faster at all sizes, with the largest gain at 1,000 elements.
ArrayList vs IntArrayList
The tables below present the benchmark results comparing java.util.ArrayList<Integer> and it.unimi.dsi.fastutil.ints.IntArrayList for the add, get, contains (hit/miss), indexOf (hit/miss), set, insertions and deletions at the beginning and middle, remove at the end, iterate, sort and clear operations.
Operation add
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.146 ± 0.005
0.049 ± 0.005
~2.97x
1000
1.978 ± 0.204
0.379 ± 0.055
~5.21x
10,000
18.837 ± 1.238
4.124 ± 0.292
~4.57x
100,000
195.039 ± 33.096
38.425 ± 4.094
~5.08x
Operation get
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.406 ± 0.003
0.410 ± 0.002
~0.99x
1000
3.746 ± 0.032
3.737 ± 0.025
~1.00x
10,000
37.192 ± 0.186
37.178 ± 0.176
~1.00x
100,000
373.070 ± 2.973
372.880 ± 2.169
~1.00x
Operation contains (hit)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.013 ± 0.000
0.007 ± 0.000
~1.81x
1000
0.137 ± 0.006
0.062 ± 0.001
~2.23x
10,000
1.762 ± 0.047
0.600 ± 0.035
~2.94x
100,000
20.908 ± 0.211
6.010 ± 0.564
~3.48x
Operation contains (miss)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.61x
1000
0.258 ± 0.002
0.069 ± 0.000
~3.73x
10,000
3.162 ± 0.094
0.698 ± 0.002
~4.53x
100,000
45.430 ± 0.653
6.931 ± 0.049
~6.55x
Operation indexOf (hit)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.012 ± 0.000
0.008 ± 0.001
~1.51x
1000
0.133 ± 0.001
0.061 ± 0.001
~2.16x
10,000
1.728 ± 0.024
0.576 ± 0.005
~3.00x
100,000
20.359 ± 0.626
5.707 ± 0.048
~3.57x
Operation indexOf (miss)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.58x
1000
0.257 ± 0.003
0.069 ± 0.001
~3.71x
10,000
3.403 ± 0.255
0.703 ± 0.006
~4.84x
100,000
45.019 ± 0.553
6.962 ± 0.055
~6.47x
Operation set (middle)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.019 ± 0.000
0.019 ± 0.000
~1.03x
1000
0.025 ± 0.008
0.022 ± 0.006
~1.14x
10,000
0.071 ± 0.008
0.062 ± 0.008
~1.15x
100,000
0.269 ± 0.071
0.167 ± 0.041
~1.62x
Operation insert at zero
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.068 ± 0.013
0.056 ± 0.010
~1.22x
1000
0.395 ± 0.141
0.406 ± 0.105
~0.97x
10,000
4.010 ± 0.910
4.172 ± 0.583
~0.96x
100,000
47.185 ± 22.218
42.105 ± 19.254
~1.12x
Operation insert at middle
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.067 ± 0.014
0.059 ± 0.009
~1.15x
1000
0.362 ± 0.125
0.397 ± 0.135
~0.91x
10,000
3.816 ± 0.761
4.230 ± 0.768
~0.90x
100,000
44.550 ± 17.131
44.663 ± 19.564
~1.00x
Operation remove (end)
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.039 ± 0.001
0.032 ± 0.000
~1.20x
1000
0.232 ± 0.014
0.227 ± 0.007
~1.02x
10,000
2.165 ± 0.033
2.170 ± 0.017
~1.00x
100,000
22.497 ± 0.307
20.963 ± 0.199
~1.07x
Operation remove at zero
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.036 ± 0.000
0.026 ± 0.000
~1.39x
1000
0.055 ± 0.007
0.043 ± 0.007
~1.28x
10,000
0.397 ± 0.028
0.419 ± 0.027
~0.95x
100,000
7.706 ± 1.370
6.462 ± 1.224
~1.19x
Operation remove at middle
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.036 ± 0.001
0.026 ± 0.000
~1.40x
1000
0.050 ± 0.008
0.034 ± 0.005
~1.45x
10,000
0.199 ± 0.016
0.217 ± 0.050
~0.92x
100,000
4.128 ± 0.434
3.769 ± 0.644
~1.10x
Operation iterate
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.034 ± 0.006
0.022 ± 0.000
~1.52x
1000
0.223 ± 0.022
0.089 ± 0.026
~2.51x
10,000
2.087 ± 0.074
0.705 ± 0.028
~2.96x
100,000
32.931 ± 1.556
7.022 ± 0.730
~4.69x
Operation sort
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
1.565 ± 0.025
0.409 ± 0.010
~3.83x
1000
22.990 ± 0.263
5.415 ± 0.220
~4.25x
10,000
664.470 ± 13.872
338.792 ± 8.842
~1.96x
100,000
8785.721 ± 95.830
4601.475 ± 71.471
~1.91x
Operation clear
Size
java.util.ArrayList (µs/op)
fastutil.IntArrayList (µs/op)
Gain (ratio)
100
0.038 ± 0.000
0.019 ± 0.000
~2.04x
1000
0.228 ± 0.009
0.021 ± 0.005
~10.94x
10,000
2.261 ± 0.063
0.060 ± 0.009
~37.73x
100,000
21.294 ± 0.739
0.123 ± 0.020
~173.58x
Observations
add: fastutil.IntArrayList is 2.97x to 5.21x faster at all sizes, with the largest gain at 1,000 elements.
get: Mixed results; fastutil.IntArrayList is faster at 1,000, 10,000, 100,000 (up to 1.00x) and java.util.ArrayList is faster at 100 (up to 1.01x).
contains (hit): fastutil.IntArrayList is 1.81x to 3.48x faster at all sizes, with the largest gain at 100,000 elements.
contains (miss): fastutil.IntArrayList is 3.61x to 6.55x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (hit): fastutil.IntArrayList is 1.51x to 3.57x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (miss): fastutil.IntArrayList is 3.58x to 6.47x faster at all sizes, with the largest gain at 100,000 elements.
set (middle): fastutil.IntArrayList is 1.03x to 1.62x faster at all sizes, with the largest gain at 100,000 elements.
insert at zero: Mixed results; fastutil.IntArrayList is faster at 100, 100,000 (up to 1.22x) and java.util.ArrayList is faster at 1,000, 10,000 (up to 1.04x).
insert at middle: Mixed results; fastutil.IntArrayList is faster at 100 (up to 1.15x) and java.util.ArrayList is faster at 1,000, 10,000, 100,000 (up to 1.11x).
remove (end): Mixed results; fastutil.IntArrayList is faster at 100, 1,000, 100,000 (up to 1.20x) and java.util.ArrayList is faster at 10,000 (up to 1.00x).
remove at zero: Mixed results; fastutil.IntArrayList is faster at 100, 1,000, 100,000 (up to 1.39x) and java.util.ArrayList is faster at 10,000 (up to 1.06x).
remove at middle: Mixed results; fastutil.IntArrayList is faster at 100, 1,000, 100,000 (up to 1.45x) and java.util.ArrayList is faster at 10,000 (up to 1.09x).
iterate: fastutil.IntArrayList is 1.52x to 4.69x faster at all sizes, with the largest gain at 100,000 elements.
sort: fastutil.IntArrayList is 1.91x to 4.25x faster at all sizes, with the largest gain at 1,000 elements.
clear: fastutil.IntArrayList is 2.04x to 173.58x faster at all sizes, with the largest gain at 100,000 elements.
HashMap vs Int2IntOpenHashMap
The tables below present the benchmark results comparing java.util.HashMap<Integer, Integer> and it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap for the put, get (hit/miss), containsKey (hit/miss), putExisting, putAll, remove, iterate over keys, values and entries, and clear operations.
Operation put
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.551 ± 0.063
0.210 ± 0.040
~2.62x
1000
5.660 ± 0.768
1.801 ± 0.160
~3.14x
10,000
56.855 ± 10.613
36.728 ± 4.164
~1.55x
100,000
625.034 ± 301.731
748.161 ± 50.257
~0.84x
Operation get (hit)
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.510 ± 0.194
0.866 ± 0.132
~0.59x
1000
5.433 ± 0.139
6.446 ± 0.247
~0.84x
10,000
63.204 ± 8.253
74.753 ± 2.478
~0.85x
100,000
1018.806 ± 244.230
714.286 ± 54.463
~1.43x
Operation get (miss)
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.199 ± 0.036
0.140 ± 0.032
~1.42x
1000
1.531 ± 0.230
1.355 ± 0.027
~1.13x
10,000
16.456 ± 3.858
23.490 ± 4.386
~0.70x
100,000
142.795 ± 43.643
620.454 ± 14.957
~0.23x
Operation containsKey (hit)
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.137 ± 0.024
0.120 ± 0.030
~1.14x
1000
1.810 ± 0.209
1.308 ± 0.007
~1.38x
10,000
20.434 ± 2.097
13.636 ± 0.594
~1.50x
100,000
295.547 ± 113.745
281.074 ± 14.105
~1.05x
Operation containsKey (miss)
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.189 ± 0.037
0.136 ± 0.033
~1.39x
1000
1.652 ± 0.442
1.350 ± 0.021
~1.22x
10,000
17.238 ± 2.937
22.050 ± 4.879
~0.78x
100,000
147.067 ± 38.052
629.185 ± 23.598
~0.23x
Operation putExisting
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.411 ± 0.023
0.115 ± 0.007
~3.57x
1000
4.998 ± 0.484
1.089 ± 0.032
~4.59x
10,000
72.946 ± 4.680
20.007 ± 3.606
~3.65x
100,000
959.214 ± 159.754
452.077 ± 55.324
~2.12x
Operation putAll
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.683 ± 0.066
0.372 ± 0.116
~1.83x
1000
6.219 ± 0.492
3.152 ± 0.346
~1.97x
10,000
59.980 ± 5.380
28.292 ± 3.781
~2.12x
100,000
923.584 ± 147.265
1004.436 ± 34.851
~0.92x
Operation remove
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.143 ± 0.011
0.236 ± 0.011
~0.61x
1000
2.277 ± 0.194
2.215 ± 0.028
~1.03x
10,000
25.379 ± 3.679
37.429 ± 7.059
~0.68x
100,000
353.743 ± 87.102
840.715 ± 81.211
~0.42x
Operation iterate
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.139 ± 0.018
0.076 ± 0.015
~1.82x
1000
1.125 ± 0.024
0.402 ± 0.013
~2.80x
10,000
12.291 ± 0.665
5.544 ± 0.981
~2.22x
100,000
424.758 ± 219.445
578.077 ± 7.607
~0.73x
Operation keySet iterate
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.130 ± 0.020
0.077 ± 0.014
~1.68x
1000
1.013 ± 0.009
0.369 ± 0.014
~2.75x
10,000
10.305 ± 0.670
5.510 ± 0.963
~1.87x
100,000
283.520 ± 100.515
576.956 ± 7.204
~0.49x
Operation values iterate
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.127 ± 0.017
0.078 ± 0.017
~1.62x
1000
1.116 ± 0.038
0.403 ± 0.019
~2.77x
10,000
10.367 ± 0.634
5.739 ± 0.881
~1.81x
100,000
228.962 ± 56.200
575.246 ± 11.677
~0.40x
Operation entrySet iterate
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.156 ± 0.010
0.077 ± 0.017
~2.03x
1000
1.339 ± 0.036
0.385 ± 0.015
~3.48x
10,000
13.842 ± 0.902
5.016 ± 0.773
~2.76x
100,000
310.210 ± 93.397
577.663 ± 13.513
~0.54x
Operation clear
Size
java.util.HashMap (µs/op)
fastutil.Int2IntOpenHashMap (µs/op)
Gain (ratio)
100
0.084 ± 0.007
0.025 ± 0.006
~3.40x
1000
0.512 ± 0.011
0.090 ± 0.003
~5.67x
10,000
3.763 ± 0.080
0.694 ± 0.083
~5.42x
100,000
58.056 ± 2.988
18.682 ± 2.365
~3.11x
Observations
put: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 3.14x) and java.util.HashMap is faster at 100,000 (up to 1.20x).
get (hit): Mixed results; fastutil.Int2IntOpenHashMap is faster at 100,000 (up to 1.43x) and java.util.HashMap is faster at 100, 1,000, 10,000 (up to 1.70x).
get (miss): Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000 (up to 1.42x) and java.util.HashMap is faster at 10,000, 100,000 (up to 4.35x).
containsKey (hit): fastutil.Int2IntOpenHashMap is 1.05x to 1.50x faster at all sizes, with the largest gain at 10,000 elements.
containsKey (miss): Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000 (up to 1.39x) and java.util.HashMap is faster at 10,000, 100,000 (up to 4.28x).
putExisting: fastutil.Int2IntOpenHashMap is 2.12x to 4.59x faster at all sizes, with the largest gain at 1,000 elements.
putAll: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 2.12x) and java.util.HashMap is faster at 100,000 (up to 1.09x).
remove: Mixed results; fastutil.Int2IntOpenHashMap is faster at 1,000 (up to 1.03x) and java.util.HashMap is faster at 100, 10,000, 100,000 (up to 2.38x).
iterate: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 2.80x) and java.util.HashMap is faster at 100,000 (up to 1.36x).
keySet iterate: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 2.75x) and java.util.HashMap is faster at 100,000 (up to 2.03x).
values iterate: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 2.77x) and java.util.HashMap is faster at 100,000 (up to 2.51x).
entrySet iterate: Mixed results; fastutil.Int2IntOpenHashMap is faster at 100, 1,000, 10,000 (up to 3.48x) and java.util.HashMap is faster at 100,000 (up to 1.86x).
clear: fastutil.Int2IntOpenHashMap is 3.11x to 5.67x faster at all sizes, with the largest gain at 1,000 elements.
agrona
ArrayList vs Agrona IntArrayList
The tables below present the benchmark results comparing java.util.ArrayList<Integer> and org.agrona.collections.IntArrayList for the add, get, contains (hit/miss), indexOf (hit/miss), set, insertions and deletions at the beginning and middle, remove at the end, iterate and clear operations. Note that sorting is not available for Agrona's IntArrayList.
Operation add
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.196 ± 0.010
0.057 ± 0.012
~3.44x
1000
2.220 ± 0.250
0.462 ± 0.072
~4.81x
10,000
18.614 ± 1.810
4.710 ± 0.479
~3.95x
100,000
197.526 ± 34.738
45.150 ± 4.267
~4.37x
Operation get
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.442 ± 0.003
0.440 ± 0.004
~1.00x
1000
3.930 ± 0.396
3.931 ± 0.388
~1.00x
10,000
36.896 ± 0.117
37.236 ± 0.541
~0.99x
100,000
369.373 ± 2.214
371.676 ± 1.630
~0.99x
Operation contains (hit)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.013 ± 0.000
0.007 ± 0.001
~1.97x
1000
0.133 ± 0.001
0.067 ± 0.005
~1.97x
10,000
1.515 ± 0.210
0.687 ± 0.057
~2.20x
100,000
17.920 ± 3.532
6.517 ± 0.703
~2.75x
Operation contains (miss)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.59x
1000
0.256 ± 0.002
0.073 ± 0.005
~3.53x
10,000
2.610 ± 0.154
0.702 ± 0.003
~3.72x
100,000
30.290 ± 0.247
6.991 ± 0.074
~4.33x
Operation indexOf (hit)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.012 ± 0.000
0.007 ± 0.000
~1.57x
1000
0.133 ± 0.000
0.062 ± 0.001
~2.14x
10,000
1.532 ± 0.216
0.577 ± 0.006
~2.66x
100,000
18.166 ± 3.939
6.728 ± 0.236
~2.70x
Operation indexOf (miss)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.60x
1000
0.257 ± 0.002
0.069 ± 0.001
~3.71x
10,000
2.830 ± 0.057
0.704 ± 0.004
~4.02x
100,000
31.124 ± 0.260
7.059 ± 0.109
~4.41x
Operation set (middle)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.019 ± 0.000
0.018 ± 0.000
~1.03x
1000
0.019 ± 0.000
0.018 ± 0.000
~1.03x
10,000
0.046 ± 0.016
0.031 ± 0.018
~1.47x
100,000
0.118 ± 0.031
0.087 ± 0.018
~1.36x
Operation insert at zero
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.072 ± 0.013
0.060 ± 0.009
~1.20x
1000
0.493 ± 0.073
0.448 ± 0.040
~1.10x
10,000
3.619 ± 0.770
3.633 ± 0.988
~1.00x
100,000
33.952 ± 7.620
35.428 ± 10.424
~0.96x
Operation insert at middle
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.066 ± 0.011
0.057 ± 0.006
~1.16x
1000
0.456 ± 0.034
0.462 ± 0.101
~0.99x
10,000
3.378 ± 0.562
3.481 ± 0.941
~0.97x
100,000
33.312 ± 7.841
33.217 ± 9.616
~1.00x
Operation remove (end)
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.038 ± 0.000
0.683 ± 0.005
~0.06x
1000
0.253 ± 0.014
13.990 ± 0.088
~0.02x
10,000
2.079 ± 0.038
695.699 ± 5.998
~0.00x
100,000
21.446 ± 1.014
98783.505 ± 825.273
~0.00x
Operation remove at zero
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.036 ± 0.000
0.026 ± 0.000
~1.39x
1000
0.049 ± 0.002
0.039 ± 0.001
~1.27x
10,000
0.253 ± 0.037
0.208 ± 0.032
~1.21x
100,000
4.219 ± 1.047
2.114 ± 0.076
~2.00x
Operation remove at middle
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.035 ± 0.000
0.025 ± 0.000
~1.38x
1000
0.042 ± 0.002
0.031 ± 0.001
~1.38x
10,000
0.148 ± 0.025
0.107 ± 0.022
~1.38x
100,000
1.714 ± 0.280
1.134 ± 0.035
~1.51x
Operation iterate
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.032 ± 0.000
0.022 ± 0.000
~1.43x
1000
0.170 ± 0.005
0.062 ± 0.000
~2.74x
10,000
1.993 ± 0.091
0.662 ± 0.005
~3.01x
100,000
29.317 ± 0.556
6.069 ± 0.149
~4.83x
Operation clear
Size
java.util.ArrayList (µs/op)
agrona.IntArrayList (µs/op)
Gain (ratio)
100
0.038 ± 0.000
0.018 ± 0.000
~2.04x
1000
0.231 ± 0.008
0.018 ± 0.000
~12.68x
10,000
2.088 ± 0.074
0.030 ± 0.020
~69.03x
100,000
20.651 ± 0.646
0.087 ± 0.016
~237.17x
Observations
add: agrona.IntArrayList is 3.44x to 4.81x faster at all sizes, with the largest gain at 1,000 elements.
get: Mixed results; agrona.IntArrayList is faster at 100 (up to 1.00x) and java.util.ArrayList is faster at 1,000, 10,000, 100,000 (up to 1.01x).
contains (hit): agrona.IntArrayList is 1.97x to 2.75x faster at all sizes, with the largest gain at 100,000 elements.
contains (miss): agrona.IntArrayList is 3.53x to 4.33x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (hit): agrona.IntArrayList is 1.57x to 2.70x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (miss): agrona.IntArrayList is 3.60x to 4.41x faster at all sizes, with the largest gain at 100,000 elements.
set (middle): agrona.IntArrayList is 1.03x to 1.47x faster at all sizes, with the largest gain at 10,000 elements.
insert at zero: Mixed results; agrona.IntArrayList is faster at 100, 1,000 (up to 1.20x) and java.util.ArrayList is faster at 10,000, 100,000 (up to 1.04x).
insert at middle: Mixed results; agrona.IntArrayList is faster at 100, 100,000 (up to 1.16x) and java.util.ArrayList is faster at 1,000, 10,000 (up to 1.03x).
remove (end): java.util.ArrayList is 18.12x to 4606.13x faster at all sizes, with the largest gain at 100,000 elements.
remove at zero: agrona.IntArrayList is 1.21x to 2.00x faster at all sizes, with the largest gain at 100,000 elements.
remove at middle: agrona.IntArrayList is 1.38x to 1.51x faster at all sizes, with the largest gain at 100,000 elements.
iterate: agrona.IntArrayList is 1.43x to 4.83x faster at all sizes, with the largest gain at 100,000 elements.
clear: agrona.IntArrayList is 2.04x to 237.17x faster at all sizes, with the largest gain at 100,000 elements.
HashMap vs Agrona Int2IntHashMap
The tables below present the benchmark results comparing java.util.HashMap<Integer, Integer> and org.agrona.collections.Int2IntHashMap for the put, get (hit/miss), containsKey (hit/miss), putExisting, putAll, remove, iterate over keys, values and entries, and clear operations.
Operation put
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.564 ± 0.052
0.353 ± 0.033
~1.60x
1000
5.793 ± 0.895
2.802 ± 0.219
~2.07x
10,000
57.855 ± 8.956
32.237 ± 3.923
~1.79x
100,000
611.553 ± 128.290
614.357 ± 50.595
~1.00x
Operation get (hit)
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.482 ± 0.020
0.671 ± 0.014
~0.72x
1000
5.522 ± 0.234
7.799 ± 0.061
~0.71x
10,000
58.662 ± 7.284
93.586 ± 0.943
~0.63x
100,000
1541.330 ± 556.281
789.863 ± 33.393
~1.95x
Operation get (miss)
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.186 ± 0.021
0.151 ± 0.002
~1.23x
1000
1.352 ± 0.221
1.776 ± 0.021
~0.76x
10,000
14.300 ± 2.943
46.589 ± 19.230
~0.31x
100,000
145.659 ± 72.379
759.932 ± 29.265
~0.19x
Operation containsKey (hit)
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.160 ± 0.026
0.158 ± 0.015
~1.01x
1000
1.873 ± 0.155
2.945 ± 0.041
~0.64x
10,000
21.664 ± 3.060
36.392 ± 23.526
~0.60x
100,000
332.347 ± 95.234
439.583 ± 16.420
~0.76x
Operation containsKey (miss)
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.177 ± 0.018
0.152 ± 0.012
~1.16x
1000
1.329 ± 0.204
2.032 ± 0.015
~0.65x
10,000
14.136 ± 2.339
56.936 ± 11.476
~0.25x
100,000
137.643 ± 40.905
766.092 ± 22.459
~0.18x
Operation putExisting
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.422 ± 0.014
0.196 ± 0.026
~2.15x
1000
4.922 ± 0.402
1.954 ± 0.024
~2.52x
10,000
75.009 ± 5.826
25.382 ± 1.299
~2.96x
100,000
1004.168 ± 182.583
488.537 ± 20.939
~2.06x
Operation putAll
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.647 ± 0.055
0.566 ± 0.050
~1.14x
1000
6.168 ± 0.406
4.383 ± 0.266
~1.41x
10,000
61.789 ± 6.294
61.436 ± 11.634
~1.01x
100,000
1094.478 ± 227.090
1192.878 ± 57.228
~0.92x
Operation remove
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.133 ± 0.008
0.252 ± 0.030
~0.53x
1000
2.364 ± 0.194
3.636 ± 0.083
~0.65x
10,000
25.806 ± 2.318
98.645 ± 10.638
~0.26x
100,000
406.409 ± 35.920
1015.812 ± 28.485
~0.40x
Operation iterate
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.138 ± 0.016
0.102 ± 0.018
~1.35x
1000
1.369 ± 0.022
0.753 ± 0.020
~1.82x
10,000
13.220 ± 1.243
10.392 ± 2.266
~1.27x
100,000
392.499 ± 90.130
633.334 ± 5.589
~0.62x
Operation keySet iterate
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.179 ± 0.005
0.199 ± 0.020
~0.90x
1000
1.726 ± 0.014
1.863 ± 0.029
~0.93x
10,000
13.859 ± 1.034
17.391 ± 1.119
~0.80x
100,000
634.665 ± 108.854
665.930 ± 6.707
~0.95x
Operation values iterate
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.175 ± 0.004
0.210 ± 0.012
~0.83x
1000
1.722 ± 0.018
1.923 ± 0.027
~0.90x
10,000
15.335 ± 2.714
18.338 ± 1.466
~0.84x
100,000
547.187 ± 130.827
688.387 ± 14.777
~0.79x
Operation entrySet iterate
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.193 ± 0.008
0.230 ± 0.011
~0.84x
1000
1.628 ± 0.013
1.997 ± 0.020
~0.82x
10,000
15.206 ± 0.969
23.616 ± 0.941
~0.64x
100,000
584.679 ± 59.326
724.250 ± 19.363
~0.81x
Operation clear
Size
java.util.HashMap (µs/op)
agrona.Int2IntHashMap (µs/op)
Gain (ratio)
100
0.075 ± 0.006
0.023 ± 0.001
~3.32x
1000
0.499 ± 0.011
0.106 ± 0.008
~4.70x
10,000
3.640 ± 0.059
0.722 ± 0.052
~5.04x
100,000
56.775 ± 1.330
18.927 ± 5.226
~3.00x
Observations
put: Mixed results; agrona.Int2IntHashMap is faster at 100, 1,000, 10,000 (up to 2.07x) and java.util.HashMap is faster at 100,000 (up to 1.00x).
get (hit): Mixed results; agrona.Int2IntHashMap is faster at 100,000 (up to 1.95x) and java.util.HashMap is faster at 100, 1,000, 10,000 (up to 1.60x).
get (miss): Mixed results; agrona.Int2IntHashMap is faster at 100 (up to 1.23x) and java.util.HashMap is faster at 1,000, 10,000, 100,000 (up to 5.22x).
containsKey (hit): Mixed results; agrona.Int2IntHashMap is faster at 100 (up to 1.01x) and java.util.HashMap is faster at 1,000, 10,000, 100,000 (up to 1.68x).
containsKey (miss): Mixed results; agrona.Int2IntHashMap is faster at 100 (up to 1.16x) and java.util.HashMap is faster at 1,000, 10,000, 100,000 (up to 5.57x).
putExisting: agrona.Int2IntHashMap is 2.06x to 2.96x faster at all sizes, with the largest gain at 10,000 elements.
putAll: Mixed results; agrona.Int2IntHashMap is faster at 100, 1,000, 10,000 (up to 1.41x) and java.util.HashMap is faster at 100,000 (up to 1.09x).
remove: java.util.HashMap is 1.54x to 3.82x faster at all sizes, with the largest gain at 10,000 elements.
iterate: Mixed results; agrona.Int2IntHashMap is faster at 100, 1,000, 10,000 (up to 1.82x) and java.util.HashMap is faster at 100,000 (up to 1.61x).
keySet iterate: java.util.HashMap is 1.05x to 1.25x faster at all sizes, with the largest gain at 10,000 elements.
values iterate: java.util.HashMap is 1.12x to 1.26x faster at all sizes, with the largest gain at 100,000 elements.
entrySet iterate: java.util.HashMap is 1.19x to 1.55x faster at all sizes, with the largest gain at 10,000 elements.
clear: agrona.Int2IntHashMap is 3.00x to 5.04x faster at all sizes, with the largest gain at 10,000 elements.
HashSet vs Agrona IntHashSet
The tables below present the benchmark results comparing java.util.HashSet<Integer> and org.agrona.collections.IntHashSet for the add, contains (hit/miss), remove, iterate, addAll, removeIf and clear operations.
Operation add
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.540 ± 0.073
0.165 ± 0.016
~3.28x
1000
5.294 ± 0.702
1.483 ± 0.109
~3.57x
10,000
53.436 ± 10.065
18.092 ± 1.636
~2.95x
100,000
618.644 ± 136.828
420.906 ± 39.806
~1.47x
Operation contains (hit)
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.181 ± 0.002
0.102 ± 0.001
~1.76x
1000
1.842 ± 0.187
1.017 ± 0.012
~1.81x
10,000
20.830 ± 2.409
12.820 ± 0.980
~1.62x
100,000
268.422 ± 33.188
335.828 ± 4.448
~0.80x
Operation contains (miss)
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.198 ± 0.030
0.102 ± 0.002
~1.94x
1000
1.522 ± 0.287
1.095 ± 0.010
~1.39x
10,000
15.082 ± 2.601
36.195 ± 18.022
~0.42x
100,000
136.932 ± 50.859
641.576 ± 9.662
~0.21x
Operation remove
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.151 ± 0.005
0.178 ± 0.001
~0.85x
1000
2.806 ± 0.208
2.404 ± 0.019
~1.17x
10,000
30.399 ± 4.855
87.626 ± 12.143
~0.35x
100,000
348.596 ± 36.119
778.217 ± 12.975
~0.45x
Operation iterate
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.347 ± 0.011
0.055 ± 0.001
~6.26x
1000
2.889 ± 0.063
0.426 ± 0.236
~6.78x
10,000
25.297 ± 0.302
8.008 ± 2.318
~3.16x
100,000
375.213 ± 15.013
601.249 ± 16.537
~0.62x
Operation addAll
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.789 ± 0.062
0.207 ± 0.011
~3.81x
1000
7.242 ± 0.572
1.828 ± 0.193
~3.96x
10,000
67.445 ± 6.415
32.302 ± 16.573
~2.09x
100,000
870.013 ± 159.648
916.276 ± 32.874
~0.95x
Operation removeIf
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.414 ± 0.005
0.191 ± 0.010
~2.17x
1000
3.966 ± 0.263
1.875 ± 0.025
~2.12x
10,000
34.674 ± 0.814
52.629 ± 10.605
~0.66x
100,000
537.922 ± 55.666
1031.026 ± 50.233
~0.52x
Operation clear
Size
java.util.HashSet (µs/op)
agrona.IntHashSet (µs/op)
Gain (ratio)
100
0.078 ± 0.004
0.021 ± 0.000
~3.71x
1000
0.481 ± 0.020
0.066 ± 0.012
~7.31x
10,000
3.629 ± 0.109
0.397 ± 0.063
~9.13x
100,000
55.729 ± 1.260
8.521 ± 1.123
~6.54x
Observations
add: agrona.IntHashSet is 1.47x to 3.57x faster at all sizes, with the largest gain at 1,000 elements.
contains (hit): Mixed results; agrona.IntHashSet is faster at 100, 1,000, 10,000 (up to 1.81x) and java.util.HashSet is faster at 100,000 (up to 1.25x).
contains (miss): Mixed results; agrona.IntHashSet is faster at 100, 1,000 (up to 1.94x) and java.util.HashSet is faster at 10,000, 100,000 (up to 4.69x).
remove: Mixed results; agrona.IntHashSet is faster at 1,000 (up to 1.17x) and java.util.HashSet is faster at 100, 10,000, 100,000 (up to 2.88x).
iterate: Mixed results; agrona.IntHashSet is faster at 100, 1,000, 10,000 (up to 6.78x) and java.util.HashSet is faster at 100,000 (up to 1.60x).
addAll: Mixed results; agrona.IntHashSet is faster at 100, 1,000, 10,000 (up to 3.96x) and java.util.HashSet is faster at 100,000 (up to 1.05x).
removeIf: Mixed results; agrona.IntHashSet is faster at 100, 1,000 (up to 2.17x) and java.util.HashSet is faster at 10,000, 100,000 (up to 1.92x).
clear: agrona.IntHashSet is 3.71x to 9.13x faster at all sizes, with the largest gain at 10,000 elements.
eclipse-collections
HashSet vs Eclipse IntHashSet
The tables below present the benchmark results comparing java.util.HashSet<Integer> and org.eclipse.collections.impl.set.mutable.primitive.IntHashSet for the add, contains (hit/miss), remove, iterate, addAll, removeIf and clear operations.
Operation add
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.524 ± 0.086
0.215 ± 0.014
~2.43x
1000
5.159 ± 1.064
2.546 ± 0.319
~2.03x
10,000
45.479 ± 6.836
30.775 ± 4.699
~1.48x
100,000
589.902 ± 95.885
541.582 ± 35.849
~1.09x
Operation contains (hit)
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.160 ± 0.031
0.111 ± 0.040
~1.43x
1000
1.831 ± 0.195
1.535 ± 0.011
~1.19x
10,000
22.095 ± 3.921
14.861 ± 0.406
~1.49x
100,000
219.720 ± 44.559
411.320 ± 11.850
~0.53x
Operation contains (miss)
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.190 ± 0.073
0.118 ± 0.005
~1.61x
1000
1.377 ± 0.327
1.632 ± 0.012
~0.84x
10,000
15.022 ± 4.540
15.415 ± 0.617
~0.97x
100,000
135.917 ± 54.089
716.733 ± 6.220
~0.19x
Operation remove
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.295 ± 0.021
0.180 ± 0.028
~1.64x
1000
2.858 ± 0.311
1.663 ± 0.014
~1.72x
10,000
30.778 ± 2.291
22.443 ± 3.018
~1.37x
100,000
342.333 ± 31.755
545.862 ± 47.860
~0.63x
Operation iterate
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.390 ± 0.039
0.089 ± 0.041
~4.41x
1000
2.874 ± 0.034
0.405 ± 0.022
~7.09x
10,000
27.562 ± 0.222
7.955 ± 0.649
~3.46x
100,000
342.511 ± 6.409
546.582 ± 6.236
~0.63x
Operation addAll
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.913 ± 0.079
0.237 ± 0.050
~3.84x
1000
7.549 ± 0.485
2.210 ± 0.097
~3.42x
10,000
73.630 ± 5.611
27.725 ± 4.480
~2.66x
100,000
853.557 ± 152.620
941.267 ± 26.141
~0.91x
Operation removeIf
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.469 ± 0.018
0.231 ± 0.044
~2.03x
1000
4.363 ± 0.150
1.506 ± 0.036
~2.90x
10,000
36.873 ± 1.430
20.724 ± 2.626
~1.78x
100,000
463.145 ± 13.023
988.870 ± 50.114
~0.47x
Operation clear
Size
java.util.HashSet (µs/op)
Eclipse IntHashSet (µs/op)
Gain (ratio)
100
0.140 ± 0.030
0.042 ± 0.016
~3.32x
1000
0.503 ± 0.015
0.073 ± 0.005
~6.93x
10,000
3.730 ± 0.208
0.960 ± 0.244
~3.88x
100,000
57.325 ± 1.182
8.210 ± 0.938
~6.98x
Observations
add: Eclipse IntHashSet is 1.09x to 2.43x faster at all sizes, with the largest gain at 100 elements.
contains (hit): Mixed results; Eclipse IntHashSet is faster at 100, 1,000, 10,000 (up to 1.49x) and java.util.HashSet is faster at 100,000 (up to 1.87x).
contains (miss): Mixed results; Eclipse IntHashSet is faster at 100 (up to 1.61x) and java.util.HashSet is faster at 1,000, 10,000, 100,000 (up to 5.27x).
remove: Mixed results; Eclipse IntHashSet is faster at 100, 1,000, 10,000 (up to 1.72x) and java.util.HashSet is faster at 100,000 (up to 1.59x).
iterate: Mixed results; Eclipse IntHashSet is faster at 100, 1,000, 10,000 (up to 7.09x) and java.util.HashSet is faster at 100,000 (up to 1.60x).
addAll: Mixed results; Eclipse IntHashSet is faster at 100, 1,000, 10,000 (up to 3.84x) and java.util.HashSet is faster at 100,000 (up to 1.10x).
removeIf: Mixed results; Eclipse IntHashSet is faster at 100, 1,000, 10,000 (up to 2.90x) and java.util.HashSet is faster at 100,000 (up to 2.14x).
clear: Eclipse IntHashSet is 3.32x to 6.98x faster at all sizes, with the largest gain at 100,000 elements.
ArrayList vs Eclipse IntArrayList
The tables below present the benchmark results comparing java.util.ArrayList<Integer> and org.eclipse.collections.impl.list.mutable.primitive.IntArrayList for the add, get, contains (hit/miss), indexOf (hit/miss), set, insertions and deletions at the beginning and middle, remove at the end, iterate, sort and clear operations.
Operation add
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.180 ± 0.009
0.097 ± 0.013
~1.86x
1000
1.994 ± 0.276
0.488 ± 0.093
~4.09x
10,000
19.171 ± 3.000
4.061 ± 0.333
~4.72x
100,000
191.089 ± 25.670
38.485 ± 9.188
~4.97x
Operation get
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.490 ± 0.033
0.498 ± 0.040
~0.98x
1000
3.785 ± 0.028
3.817 ± 0.024
~0.99x
10,000
37.024 ± 0.208
37.323 ± 0.189
~0.99x
100,000
371.153 ± 4.374
373.407 ± 1.689
~0.99x
Operation contains (hit)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.022 ± 0.000
0.007 ± 0.000
~2.98x
1000
0.133 ± 0.001
0.063 ± 0.001
~2.12x
10,000
1.732 ± 0.008
0.608 ± 0.035
~2.85x
100,000
20.000 ± 0.856
6.606 ± 0.205
~3.03x
Operation contains (miss)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.008 ± 0.001
~3.49x
1000
0.257 ± 0.003
0.070 ± 0.000
~3.67x
10,000
3.116 ± 0.145
0.708 ± 0.005
~4.40x
100,000
45.946 ± 1.153
6.978 ± 0.033
~6.58x
Operation indexOf (hit)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.018 ± 0.001
0.008 ± 0.001
~2.31x
1000
0.132 ± 0.000
0.062 ± 0.000
~2.13x
10,000
1.682 ± 0.072
0.579 ± 0.004
~2.90x
100,000
19.339 ± 0.990
5.757 ± 0.085
~3.36x
Operation indexOf (miss)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.56x
1000
0.270 ± 0.022
0.070 ± 0.001
~3.87x
10,000
3.419 ± 0.138
0.706 ± 0.003
~4.85x
100,000
45.146 ± 0.441
6.987 ± 0.128
~6.46x
Operation set (middle)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.019 ± 0.000
0.019 ± 0.001
~1.01x
1000
0.075 ± 0.049
0.076 ± 0.053
~0.98x
10,000
0.158 ± 0.030
0.160 ± 0.029
~0.99x
100,000
0.293 ± 0.079
0.393 ± 0.438
~0.74x
Operation insert at zero
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.094 ± 0.022
0.050 ± 0.011
~1.87x
1000
0.399 ± 0.057
0.363 ± 0.073
~1.10x
10,000
4.391 ± 1.365
4.279 ± 1.254
~1.03x
100,000
42.298 ± 16.443
38.445 ± 10.047
~1.10x
Operation insert at middle
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.085 ± 0.018
0.064 ± 0.012
~1.32x
1000
0.399 ± 0.060
0.382 ± 0.084
~1.04x
10,000
3.942 ± 0.828
4.047 ± 1.177
~0.97x
100,000
38.035 ± 19.030
39.748 ± 11.042
~0.96x
Operation remove (end)
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.060 ± 0.008
0.080 ± 0.011
~0.75x
1000
0.304 ± 0.036
0.459 ± 0.030
~0.66x
10,000
2.706 ± 0.361
3.883 ± 0.136
~0.70x
100,000
23.075 ± 1.097
35.854 ± 1.317
~0.64x
Operation remove at zero
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.063 ± 0.009
0.054 ± 0.008
~1.16x
1000
0.137 ± 0.039
0.108 ± 0.033
~1.26x
10,000
0.847 ± 0.217
0.749 ± 0.095
~1.13x
100,000
7.263 ± 1.408
9.241 ± 1.609
~0.79x
Operation remove at middle
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.063 ± 0.010
0.054 ± 0.008
~1.16x
1000
0.125 ± 0.041
0.108 ± 0.046
~1.16x
10,000
0.441 ± 0.098
0.393 ± 0.074
~1.12x
100,000
3.697 ± 0.495
4.726 ± 2.495
~0.78x
Operation iterate
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.034 ± 0.004
0.024 ± 0.005
~1.41x
1000
0.279 ± 0.052
0.139 ± 0.023
~2.00x
10,000
2.218 ± 0.431
0.780 ± 0.126
~2.84x
100,000
32.893 ± 2.557
6.705 ± 0.609
~4.91x
Operation sort
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
1.590 ± 0.012
0.461 ± 0.011
~3.45x
1000
20.568 ± 0.242
5.573 ± 0.064
~3.69x
10,000
656.374 ± 12.475
265.636 ± 5.790
~2.47x
100,000
8823.187 ± 126.341
3639.415 ± 51.695
~2.42x
Operation clear
Size
java.util.ArrayList (µs/op)
Eclipse IntArrayList (µs/op)
Gain (ratio)
100
0.056 ± 0.009
0.020 ± 0.000
~2.78x
1000
0.307 ± 0.043
0.116 ± 0.054
~2.65x
10,000
2.197 ± 0.037
0.289 ± 0.037
~7.60x
100,000
20.740 ± 0.353
2.167 ± 0.719
~9.57x
Observations
add: Eclipse IntArrayList is 1.86x to 4.97x faster at all sizes, with the largest gain at 100,000 elements.
get: java.util.ArrayList is 1.01x to 1.02x faster at all sizes, with the largest gain at 100 elements.
contains (hit): Eclipse IntArrayList is 2.12x to 3.03x faster at all sizes, with the largest gain at 100,000 elements.
contains (miss): Eclipse IntArrayList is 3.49x to 6.58x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (hit): Eclipse IntArrayList is 2.13x to 3.36x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (miss): Eclipse IntArrayList is 3.56x to 6.46x faster at all sizes, with the largest gain at 100,000 elements.
set (middle): Mixed results; Eclipse IntArrayList is faster at 100 (up to 1.01x) and java.util.ArrayList is faster at 1,000, 10,000, 100,000 (up to 1.34x).
insert at zero: Eclipse IntArrayList is 1.03x to 1.87x faster at all sizes, with the largest gain at 100 elements.
insert at middle: Mixed results; Eclipse IntArrayList is faster at 100, 1,000 (up to 1.32x) and java.util.ArrayList is faster at 10,000, 100,000 (up to 1.05x).
remove (end): java.util.ArrayList is 1.34x to 1.55x faster at all sizes, with the largest gain at 100,000 elements.
remove at zero: Mixed results; Eclipse IntArrayList is faster at 100, 1,000, 10,000 (up to 1.26x) and java.util.ArrayList is faster at 100,000 (up to 1.27x).
remove at middle: Mixed results; Eclipse IntArrayList is faster at 100, 1,000, 10,000 (up to 1.16x) and java.util.ArrayList is faster at 100,000 (up to 1.28x).
iterate: Eclipse IntArrayList is 1.41x to 4.91x faster at all sizes, with the largest gain at 100,000 elements.
sort: Eclipse IntArrayList is 2.42x to 3.69x faster at all sizes, with the largest gain at 1,000 elements.
clear: Eclipse IntArrayList is 2.65x to 9.57x faster at all sizes, with the largest gain at 100,000 elements.
HashMap vs MutableIntIntMap
The tables below present the benchmark results comparing java.util.HashMap<Integer, Integer> and org.eclipse.collections.impl.map.mutable.primitive.IntIntHashMap for the put, get (hit/miss), containsKey (hit/miss), putExisting, putAll, remove, iterate over keys, values and entries, and clear operations.
Operation put
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.626 ± 0.035
0.330 ± 0.048
~1.90x
1000
5.825 ± 1.067
2.480 ± 0.517
~2.35x
10,000
54.024 ± 8.854
27.243 ± 3.512
~1.98x
100,000
773.570 ± 320.748
290.230 ± 99.876
~2.67x
Operation get (hit)
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.604 ± 0.089
0.582 ± 0.064
~1.04x
1000
5.567 ± 0.151
4.167 ± 0.039
~1.34x
10,000
64.589 ± 6.947
40.720 ± 0.211
~1.59x
100,000
1108.450 ± 164.992
418.992 ± 11.581
~2.65x
Operation get (miss)
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.230 ± 0.035
0.063 ± 0.007
~3.62x
1000
1.534 ± 0.175
0.524 ± 0.011
~2.93x
10,000
15.451 ± 2.490
4.141 ± 0.067
~3.73x
100,000
135.599 ± 52.137
42.492 ± 1.088
~3.19x
Operation containsKey (hit)
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.592 ± 0.080
0.593 ± 0.049
~1.00x
1000
5.326 ± 0.156
4.078 ± 0.078
~1.31x
10,000
56.104 ± 5.581
39.489 ± 0.630
~1.42x
100,000
1024.660 ± 151.226
421.628 ± 17.533
~2.43x
Operation containsKey (miss)
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.227 ± 0.052
0.067 ± 0.012
~3.40x
1000
1.460 ± 0.172
0.545 ± 0.031
~2.68x
10,000
15.169 ± 3.634
4.257 ± 0.120
~3.56x
100,000
128.285 ± 49.253
42.642 ± 1.246
~3.01x
Operation putExisting
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.539 ± 0.037
0.210 ± 0.025
~2.57x
1000
6.299 ± 0.350
1.017 ± 0.097
~6.20x
10,000
71.430 ± 7.387
9.098 ± 0.248
~7.85x
100,000
851.991 ± 99.769
90.302 ± 5.995
~9.43x
Operation putAll
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.743 ± 0.054
0.339 ± 0.040
~2.19x
1000
6.718 ± 0.509
2.120 ± 0.300
~3.17x
10,000
60.658 ± 5.933
28.296 ± 8.137
~2.14x
100,000
780.222 ± 151.110
237.838 ± 75.999
~3.28x
Operation remove
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.327 ± 0.074
0.257 ± 0.022
~1.27x
1000
2.489 ± 0.157
1.129 ± 0.016
~2.20x
10,000
30.300 ± 3.045
10.676 ± 0.301
~2.84x
100,000
416.994 ± 80.798
103.273 ± 1.523
~4.04x
Operation iterate
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.170 ± 0.084
0.104 ± 0.079
~1.63x
1000
1.186 ± 0.038
0.402 ± 0.013
~2.95x
10,000
11.630 ± 0.645
6.396 ± 0.243
~1.82x
100,000
208.600 ± 46.080
56.506 ± 4.283
~3.69x
Operation keySet iterate
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.160 ± 0.083
0.092 ± 0.054
~1.73x
1000
1.096 ± 0.009
0.528 ± 0.018
~2.08x
10,000
9.294 ± 0.900
6.063 ± 0.304
~1.53x
100,000
144.443 ± 14.238
55.242 ± 1.978
~2.61x
Operation values iterate
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.154 ± 0.077
0.117 ± 0.081
~1.32x
1000
1.211 ± 0.053
0.560 ± 0.011
~2.16x
10,000
10.067 ± 0.975
6.991 ± 0.268
~1.44x
100,000
184.690 ± 18.006
64.152 ± 2.489
~2.88x
Operation entrySet iterate
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.185 ± 0.072
0.094 ± 0.076
~1.97x
1000
1.399 ± 0.043
0.432 ± 0.009
~3.24x
10,000
13.698 ± 0.408
4.500 ± 0.075
~3.04x
100,000
197.923 ± 18.273
41.225 ± 2.716
~4.80x
Operation clear
Size
java.util.HashMap (µs/op)
Eclipse IntIntHashMap (µs/op)
Gain (ratio)
100
0.187 ± 0.025
0.121 ± 0.032
~1.54x
1000
0.574 ± 0.009
0.199 ± 0.021
~2.89x
10,000
3.802 ± 0.091
2.857 ± 1.132
~1.33x
100,000
59.271 ± 2.054
20.397 ± 6.051
~2.91x
Observations
put: Eclipse IntIntHashMap is 1.90x to 2.67x faster at all sizes, with the largest gain at 100,000 elements.
get (hit): Eclipse IntIntHashMap is 1.04x to 2.65x faster at all sizes, with the largest gain at 100,000 elements.
get (miss): Eclipse IntIntHashMap is 2.93x to 3.73x faster at all sizes, with the largest gain at 10,000 elements.
containsKey (hit): Mixed results; Eclipse IntIntHashMap is faster at 1,000, 10,000, 100,000 (up to 2.43x) and java.util.HashMap is faster at 100 (up to 1.00x).
containsKey (miss): Eclipse IntIntHashMap is 2.68x to 3.56x faster at all sizes, with the largest gain at 10,000 elements.
putExisting: Eclipse IntIntHashMap is 2.57x to 9.43x faster at all sizes, with the largest gain at 100,000 elements.
putAll: Eclipse IntIntHashMap is 2.14x to 3.28x faster at all sizes, with the largest gain at 100,000 elements.
remove: Eclipse IntIntHashMap is 1.27x to 4.04x faster at all sizes, with the largest gain at 100,000 elements.
iterate: Eclipse IntIntHashMap is 1.63x to 3.69x faster at all sizes, with the largest gain at 100,000 elements.
keySet iterate: Eclipse IntIntHashMap is 1.53x to 2.61x faster at all sizes, with the largest gain at 100,000 elements.
values iterate: Eclipse IntIntHashMap is 1.32x to 2.88x faster at all sizes, with the largest gain at 100,000 elements.
entrySet iterate: Eclipse IntIntHashMap is 1.97x to 4.80x faster at all sizes, with the largest gain at 100,000 elements.
clear: Eclipse IntIntHashMap is 1.33x to 2.91x faster at all sizes, with the largest gain at 100,000 elements.
HPPC
HashMap vs IntIntMap
The tables below present the benchmark results comparing java.util.HashMap<Integer, Integer> and com.carrotsearch.hppc.IntIntMap for the put, get (hit/miss), containsKey (hit/miss), putExisting, putAll, remove, iterate over keys, values and entries, and clear operations.
Operation put
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.485 ± 0.047
0.204 ± 0.055
~2.38x
1000
5.715 ± 1.187
1.997 ± 0.445
~2.86x
10,000
53.056 ± 13.689
39.813 ± 7.312
~1.33x
100,000
661.178 ± 284.081
444.749 ± 98.144
~1.49x
Operation get (hit)
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.471 ± 0.053
0.798 ± 0.046
~0.59x
1000
5.544 ± 0.407
6.386 ± 0.591
~0.87x
10,000
64.309 ± 6.923
71.933 ± 0.454
~0.89x
100,000
1321.393 ± 425.457
661.383 ± 5.013
~2.00x
Operation get (miss)
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.656 ± 0.069
1.054 ± 0.058
~0.62x
1000
4.616 ± 0.574
11.522 ± 0.410
~0.40x
10,000
73.451 ± 3.007
133.249 ± 0.644
~0.55x
100,000
451.854 ± 35.146
1000.356 ± 21.849
~0.45x
Operation containsKey (hit)
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.146 ± 0.035
0.085 ± 0.007
~1.71x
1000
1.838 ± 0.444
1.751 ± 0.011
~1.05x
10,000
21.055 ± 3.551
30.914 ± 4.976
~0.68x
100,000
420.837 ± 132.799
258.180 ± 18.993
~1.63x
Operation containsKey (miss)
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.223 ± 0.093
0.098 ± 0.005
~2.28x
1000
1.471 ± 0.322
0.915 ± 0.032
~1.61x
10,000
16.880 ± 4.037
71.119 ± 2.616
~0.24x
100,000
159.859 ± 47.297
573.970 ± 9.947
~0.28x
Operation putExisting
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.384 ± 0.062
0.197 ± 0.024
~1.95x
1000
4.603 ± 0.644
3.263 ± 0.551
~1.41x
10,000
72.788 ± 9.948
46.880 ± 0.447
~1.55x
100,000
925.417 ± 189.140
381.106 ± 35.067
~2.43x
Operation putAll
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.679 ± 0.065
0.396 ± 0.039
~1.72x
1000
6.216 ± 0.966
7.896 ± 0.555
~0.79x
10,000
58.202 ± 5.889
123.306 ± 6.411
~0.47x
100,000
1113.493 ± 259.988
1545.720 ± 98.944
~0.72x
Operation remove
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.156 ± 0.020
0.296 ± 0.023
~0.53x
1000
2.517 ± 0.367
4.597 ± 0.117
~0.55x
10,000
28.363 ± 5.021
100.236 ± 4.733
~0.28x
100,000
487.097 ± 169.512
968.565 ± 77.426
~0.50x
Operation iterate
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.147 ± 0.022
0.217 ± 0.009
~0.67x
1000
1.336 ± 0.035
6.637 ± 0.262
~0.20x
10,000
14.503 ± 1.346
70.851 ± 2.016
~0.20x
100,000
423.293 ± 80.884
1012.899 ± 26.168
~0.42x
Operation keySet iterate
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.124 ± 0.021
0.191 ± 0.024
~0.65x
1000
1.024 ± 0.018
6.678 ± 0.249
~0.15x
10,000
11.003 ± 0.932
64.923 ± 0.814
~0.17x
100,000
222.594 ± 31.630
989.759 ± 18.349
~0.22x
Operation values iterate
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.122 ± 0.029
0.341 ± 0.099
~0.36x
1000
1.106 ± 0.046
6.721 ± 0.134
~0.16x
10,000
11.201 ± 0.894
67.511 ± 0.408
~0.17x
100,000
307.435 ± 60.156
1024.624 ± 10.385
~0.30x
Operation entrySet iterate
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.149 ± 0.018
0.216 ± 0.010
~0.69x
1000
1.336 ± 0.072
7.177 ± 0.171
~0.19x
10,000
13.942 ± 0.807
70.900 ± 2.029
~0.20x
100,000
293.688 ± 89.954
1028.549 ± 29.607
~0.29x
Operation clear
Size
java.util.HashMap (µs/op)
HPPC IntIntMap (µs/op)
Gain (ratio)
100
0.080 ± 0.007
0.024 ± 0.005
~3.40x
1000
0.505 ± 0.019
0.077 ± 0.011
~6.57x
10,000
3.668 ± 0.118
0.347 ± 0.039
~10.56x
100,000
58.430 ± 2.291
9.258 ± 0.800
~6.31x
Observations
put: HPPC IntIntMap is 1.33x to 2.86x faster at all sizes, with the largest gain at 1,000 elements.
get (hit): Mixed results; HPPC IntIntMap is faster at 100,000 (up to 2.00x) and java.util.HashMap is faster at 100, 1,000, 10,000 (up to 1.70x).
get (miss): java.util.HashMap is 1.61x to 2.50x faster at all sizes, with the largest gain at 1,000 elements.
containsKey (hit): Mixed results; HPPC IntIntMap is faster at 100, 1,000, 100,000 (up to 1.71x) and java.util.HashMap is faster at 10,000 (up to 1.47x).
containsKey (miss): Mixed results; HPPC IntIntMap is faster at 100, 1,000 (up to 2.28x) and java.util.HashMap is faster at 10,000, 100,000 (up to 4.21x).
putExisting: HPPC IntIntMap is 1.41x to 2.43x faster at all sizes, with the largest gain at 100,000 elements.
putAll: Mixed results; HPPC IntIntMap is faster at 100 (up to 1.72x) and java.util.HashMap is faster at 1,000, 10,000, 100,000 (up to 2.12x).
remove: java.util.HashMap is 1.83x to 3.53x faster at all sizes, with the largest gain at 10,000 elements.
iterate: java.util.HashMap is 1.48x to 4.97x faster at all sizes, with the largest gain at 1,000 elements.
keySet iterate: java.util.HashMap is 1.54x to 6.52x faster at all sizes, with the largest gain at 1,000 elements.
values iterate: java.util.HashMap is 2.79x to 6.08x faster at all sizes, with the largest gain at 1,000 elements.
entrySet iterate: java.util.HashMap is 1.45x to 5.37x faster at all sizes, with the largest gain at 1,000 elements.
clear: HPPC IntIntMap is 3.40x to 10.56x faster at all sizes, with the largest gain at 10,000 elements.
ArrayList vs HPPC IntArrayList
The tables below present the benchmark results comparing java.util.ArrayList<Integer> and com.carrotsearch.hppc.IntArrayList for the add, get, contains (hit/miss), indexOf (hit/miss), set, insertions and deletions at the beginning and middle, remove at the end, iterate, sort and clear operations.
Operation add
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.174 ± 0.034
0.063 ± 0.003
~2.77x
1000
1.928 ± 0.239
0.411 ± 0.080
~4.69x
10,000
18.385 ± 2.244
4.220 ± 0.329
~4.36x
100,000
193.880 ± 39.532
46.949 ± 21.712
~4.13x
Operation get
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.487 ± 0.064
0.461 ± 0.085
~1.06x
1000
3.802 ± 0.109
3.758 ± 0.030
~1.01x
10,000
37.366 ± 0.254
37.148 ± 0.157
~1.01x
100,000
374.115 ± 8.144
371.966 ± 3.201
~1.01x
Operation contains (hit)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.013 ± 0.000
0.007 ± 0.000
~1.88x
1000
0.133 ± 0.001
0.061 ± 0.001
~2.17x
10,000
1.723 ± 0.020
0.577 ± 0.015
~2.99x
100,000
19.225 ± 3.904
6.076 ± 0.650
~3.16x
Operation contains (miss)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.59x
1000
0.256 ± 0.002
0.069 ± 0.001
~3.69x
10,000
3.107 ± 0.133
0.696 ± 0.004
~4.46x
100,000
46.636 ± 0.867
6.922 ± 0.047
~6.74x
Operation indexOf (hit)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.012 ± 0.000
0.008 ± 0.000
~1.59x
1000
0.132 ± 0.001
0.062 ± 0.001
~2.12x
10,000
1.735 ± 0.020
0.575 ± 0.004
~3.02x
100,000
19.837 ± 1.531
5.756 ± 0.107
~3.45x
Operation indexOf (miss)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.027 ± 0.000
0.007 ± 0.000
~3.60x
1000
0.256 ± 0.003
0.069 ± 0.001
~3.69x
10,000
3.456 ± 0.150
0.700 ± 0.007
~4.94x
100,000
45.205 ± 0.374
6.968 ± 0.096
~6.49x
Operation set (middle)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.020 ± 0.001
0.019 ± 0.000
~1.05x
1000
0.042 ± 0.011
0.036 ± 0.013
~1.17x
10,000
0.139 ± 0.048
0.102 ± 0.037
~1.37x
100,000
0.846 ± 1.238
0.365 ± 0.540
~2.32x
Operation insert at zero
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.070 ± 0.010
0.056 ± 0.009
~1.24x
1000
0.235 ± 0.076
0.340 ± 0.063
~0.69x
10,000
3.897 ± 1.074
4.038 ± 0.954
~0.97x
100,000
35.953 ± 15.319
52.800 ± 22.882
~0.68x
Operation insert at middle
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.072 ± 0.011
0.056 ± 0.010
~1.29x
1000
0.236 ± 0.072
0.315 ± 0.063
~0.75x
10,000
3.400 ± 0.637
3.361 ± 0.605
~1.01x
100,000
38.956 ± 16.432
43.061 ± 22.466
~0.90x
Operation remove (end)
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.039 ± 0.001
0.085 ± 0.001
~0.45x
1000
0.259 ± 0.028
0.943 ± 0.030
~0.27x
10,000
2.462 ± 0.088
8.987 ± 0.206
~0.27x
100,000
22.826 ± 1.255
90.682 ± 3.000
~0.25x
Operation remove at zero
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.037 ± 0.001
0.026 ± 0.001
~1.45x
1000
0.073 ± 0.016
0.078 ± 0.025
~0.94x
10,000
0.490 ± 0.089
0.380 ± 0.072
~1.29x
100,000
8.474 ± 5.154
7.309 ± 4.800
~1.16x
Operation remove at middle
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.035 ± 0.001
0.025 ± 0.001
~1.39x
1000
0.068 ± 0.021
0.053 ± 0.021
~1.27x
10,000
0.333 ± 0.048
0.198 ± 0.028
~1.68x
100,000
4.579 ± 2.492
4.538 ± 3.329
~1.01x
Operation iterate
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.033 ± 0.002
0.055 ± 0.003
~0.61x
1000
0.234 ± 0.005
1.344 ± 0.023
~0.17x
10,000
2.550 ± 0.387
13.107 ± 0.124
~0.19x
100,000
32.747 ± 5.215
140.260 ± 14.671
~0.23x
Operation sort
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
1.712 ± 0.054
0.439 ± 0.004
~3.90x
1000
22.940 ± 0.236
5.469 ± 0.049
~4.19x
10,000
668.543 ± 15.368
269.653 ± 11.318
~2.48x
100,000
8903.287 ± 180.488
3659.008 ± 22.781
~2.43x
Operation clear
Size
java.util.ArrayList (µs/op)
HPPC IntArrayList (µs/op)
Gain (ratio)
100
0.038 ± 0.001
0.021 ± 0.001
~1.78x
1000
0.243 ± 0.025
0.045 ± 0.015
~5.45x
10,000
2.144 ± 0.039
0.227 ± 0.024
~9.43x
100,000
20.645 ± 0.324
2.103 ± 0.780
~9.82x
Observations
add: HPPC IntArrayList is 2.77x to 4.69x faster at all sizes, with the largest gain at 1,000 elements.
get: HPPC IntArrayList is 1.01x to 1.06x faster at all sizes, with the largest gain at 100 elements.
contains (hit): HPPC IntArrayList is 1.88x to 3.16x faster at all sizes, with the largest gain at 100,000 elements.
contains (miss): HPPC IntArrayList is 3.59x to 6.74x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (hit): HPPC IntArrayList is 1.59x to 3.45x faster at all sizes, with the largest gain at 100,000 elements.
indexOf (miss): HPPC IntArrayList is 3.60x to 6.49x faster at all sizes, with the largest gain at 100,000 elements.
set (middle): HPPC IntArrayList is 1.05x to 2.32x faster at all sizes, with the largest gain at 100,000 elements.
insert at zero: Mixed results; HPPC IntArrayList is faster at 100 (up to 1.24x) and java.util.ArrayList is faster at 1,000, 10,000, 100,000 (up to 1.47x).
insert at middle: Mixed results; HPPC IntArrayList is faster at 100, 10,000 (up to 1.29x) and java.util.ArrayList is faster at 1,000, 100,000 (up to 1.33x).
remove (end): java.util.ArrayList is 2.20x to 3.97x faster at all sizes, with the largest gain at 100,000 elements.
remove at zero: Mixed results; HPPC IntArrayList is faster at 100, 10,000, 100,000 (up to 1.45x) and java.util.ArrayList is faster at 1,000 (up to 1.06x).
remove at middle: HPPC IntArrayList is 1.01x to 1.68x faster at all sizes, with the largest gain at 10,000 elements.
iterate: java.util.ArrayList is 1.64x to 5.74x faster at all sizes, with the largest gain at 1,000 elements.
sort: HPPC IntArrayList is 2.43x to 4.19x faster at all sizes, with the largest gain at 1,000 elements.
clear: HPPC IntArrayList is 1.78x to 9.82x faster at all sizes, with the largest gain at 100,000 elements.
HashSet vs HPPC IntHashSet
The tables below present the benchmark results comparing java.util.HashSet<Integer> and com.carrotsearch.hppc.IntHashSet for the add, contains (hit/miss), remove, iterate, addAll, removeAll and clear operations.
Operation add
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.551 ± 0.063
0.160 ± 0.019
~3.44x
1000
5.096 ± 0.700
1.131 ± 0.080
~4.51x
10,000
56.074 ± 14.134
31.697 ± 4.780
~1.77x
100,000
833.974 ± 501.248
327.045 ± 34.311
~2.55x
Operation contains (hit)
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.146 ± 0.026
0.087 ± 0.008
~1.67x
1000
1.815 ± 0.177
0.729 ± 0.025
~2.49x
10,000
21.000 ± 2.156
33.981 ± 1.625
~0.62x
100,000
260.976 ± 59.783
252.989 ± 6.278
~1.03x
Operation contains (miss)
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.180 ± 0.026
0.102 ± 0.011
~1.77x
1000
1.498 ± 0.210
0.946 ± 0.030
~1.58x
10,000
18.700 ± 6.828
82.130 ± 1.484
~0.23x
100,000
163.146 ± 29.883
606.744 ± 12.705
~0.27x
Operation remove
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.167 ± 0.023
0.281 ± 0.039
~0.59x
1000
2.748 ± 0.144
3.927 ± 0.338
~0.70x
10,000
30.438 ± 3.610
86.516 ± 1.687
~0.35x
100,000
494.806 ± 151.036
747.162 ± 84.387
~0.66x
Operation iterate
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.363 ± 0.019
0.340 ± 0.064
~1.07x
1000
2.896 ± 0.087
6.752 ± 0.543
~0.43x
10,000
25.775 ± 0.536
66.449 ± 0.572
~0.39x
100,000
389.330 ± 37.339
951.110 ± 10.776
~0.41x
Operation addAll
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.852 ± 0.068
0.409 ± 0.173
~2.08x
1000
7.559 ± 0.810
6.977 ± 0.313
~1.08x
10,000
71.459 ± 9.634
110.227 ± 2.696
~0.65x
100,000
1091.105 ± 238.879
1426.877 ± 109.263
~0.76x
Operation removeAll
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.420 ± 0.024
0.303 ± 0.073
~1.38x
1000
3.682 ± 0.274
2.923 ± 0.130
~1.26x
10,000
32.299 ± 1.028
89.840 ± 1.389
~0.36x
100,000
502.300 ± 102.739
845.482 ± 17.882
~0.59x
Operation clear
Size
java.util.HashSet (µs/op)
HPPC IntHashSet (µs/op)
Gain (ratio)
100
0.084 ± 0.008
0.025 ± 0.007
~3.35x
1000
0.505 ± 0.021
0.077 ± 0.010
~6.56x
10,000
3.675 ± 0.134
0.373 ± 0.077
~9.85x
100,000
59.013 ± 3.688
9.595 ± 0.851
~6.15x
Observations
add: HPPC IntHashSet is 1.77x to 4.51x faster at all sizes, with the largest gain at 1,000 elements.
contains (hit): Mixed results; HPPC IntHashSet is faster at 100, 1,000, 100,000 (up to 2.49x) and java.util.HashSet is faster at 10,000 (up to 1.62x).
contains (miss): Mixed results; HPPC IntHashSet is faster at 100, 1,000 (up to 1.77x) and java.util.HashSet is faster at 10,000, 100,000 (up to 4.39x).
remove: java.util.HashSet is 1.43x to 2.84x faster at all sizes, with the largest gain at 10,000 elements.
iterate: Mixed results; HPPC IntHashSet is faster at 100 (up to 1.07x) and java.util.HashSet is faster at 1,000, 10,000, 100,000 (up to 2.58x).
addAll: Mixed results; HPPC IntHashSet is faster at 100, 1,000 (up to 2.08x) and java.util.HashSet is faster at 10,000, 100,000 (up to 1.54x).
removeAll: Mixed results; HPPC IntHashSet is faster at 100, 1,000 (up to 1.38x) and java.util.HashSet is faster at 10,000, 100,000 (up to 2.78x).
clear: HPPC IntHashSet is 3.35x to 9.85x faster at all sizes, with the largest gain at 10,000 elements.