Liking cljdoc? Tell your friends :D

Benchmarks Results

Test Methods

Running tests

lein with-profile bench,small-heap,parallel run

Benchmarks framework

Criterium is used to run quick benchmarks.

Profiles

Benchmarks are run on all combinations of the following:

  • heap size: big (9G), medium (5G), small (2G).
  • Garbage collection: parallel, G1

Tests details

assoc

Assoc and fast assoc performance are tested with maps and records.

assoc-in

Assoc-in is tested vs. an inlined implementation with vanilla maps, gets and assoc, all core functions.

get

get was tested on map, record and fast-map, fast-get was tested on fast-map.

Moreover, different get methods were tested:

  • map on keyword.
  • keyword on map.
  • keyword on record.
  • .get from record.
  • .field from record.

merge

Fast map merge

fast map merge was implemented by Metosin and uses kv-reduce to assoc one map into another. Was compared vs. regular merge.

Inline Merge

Two different implementations of inlining merge were tested, one based on the core implementation of merge, and one on Metosin's.

get-in

get-in was tested against an inlined implementation.

select-keys

select-keys was tested against an inlined implementation.

Results Summary

assoc

NOTE: the first result is surprising as it does not correlate with benchmarks run in the REPL. Requires further study.

  • assoc to record ~twice as fast as associng to map.
  • fast-assoc ~ 5.7% faster than assoc. (Metosin)

Assoc-in

  • the inlined implementation is always faster and exhibits compounding returns for deeper maps.

get

NOTE: Same case as the assoc experiment, with benchmarks results being the opposite of what's measured in a running REPL.

  • get from record ~50% slower than from map.
  • fast-get from fast-map ~ 8.4% faster than getting from regular map. (Metosin)
  • map on keyword > keyword on map > get from map (ordered by speed)
  • field from record > keyword on record > .get from record > get from record.

merge

Fast Map merge

Distinctly faster than regular merge, by about 30%, but differences might depend on map sizes, so more benchmarks are required.

Inline merge & fast merge

Sees diminishing returns on the benefit of merging more maps, but the speedup is measurable.

get-in

Inline implementation faster by a factor of 4-5.

select-keys

Inline implementation faster by a factor of 10 or more, depends on the number of selected keys.

heapgctestexecution time mean
bigg1assoc to map60.603761 ns
bigg1assoc to record38.332317 ns
bigg1fast-assoc to map58.735587 ns
bigg1fast-assoc to record39.049585 ns
bigg1assoc-in 159.427094 ns
bigg1assoc-in 287.421121 ns
bigg1assoc-in 3184.219410 ns
bigg1assoc-in 4211.092112 ns
bigg1inline-assoc-in 139.376813 ns
bigg1inline-assoc-in 2125.912361 ns
bigg1inline-assoc-in 3139.318034 ns
bigg1inline-assoc-in 4148.861730 ns
bigg1update-in 1152.947998 ns
bigg1inline-update-in 1147.596307 ns
bigg1update-in 2212.675980 ns
bigg1inline-update-in 2163.617075 ns
bigg1update-in 3255.303195 ns
bigg1inline-update-in 3191.001550 ns
bigg1update-in 4294.511887 ns
bigg1inline-update-in 4217.878713 ns
bigg1get from map11.339306 ns
bigg1map on keyword8.574417 ns
bigg1keyword on map10.460608 ns
bigg1get from record14.457372 ns
bigg1keyword on record5.998421 ns
bigg1.get from record12.510472 ns
bigg1get field from record3.684584 ns
bigg1get from fast-map38.197091 ns
bigg1fast-get from fast-map7.799408 ns
bigg1merge maps457.884247 ns
bigg1fast merge maps341.036887 ns
bigg1merge 2 maps506.583409 ns
bigg1inline merge 2 maps420.007590 ns
bigg1inline fast merge 2 maps344.121518 ns
bigg1merge 3 maps1.664652 µs
bigg1inline merge 3 maps1.490882 µs
bigg1inline fast merge 3 maps1.443558 µs
bigg1merge 4 maps1.954119 µs
bigg1inline merge 4 maps1.797741 µs
bigg1inline fast merge 4 maps1.774046 µs
bigg1get-in 139.786330 ns
bigg1fast get-in 110.344779 ns
bigg1get some in 15.947930 ns
bigg1get-in 257.110968 ns
bigg1fast get-in 218.057849 ns
bigg1get some in 210.442508 ns
bigg1get-in 373.667482 ns
bigg1fast get-in 325.383331 ns
bigg1get some in 313.199312 ns
bigg1get-in 486.140015 ns
bigg1fast get-in 433.072601 ns
bigg1get some in 417.824613 ns
bigg1select 1/4 keys192.296473 ns
bigg1fast select 1/4 keys24.456551 ns
bigg1select 2/4 keys276.708812 ns
bigg1fast select 2/4 keys32.690009 ns
bigg1select 3/4 keys366.079642 ns
bigg1fast select 3/4 keys44.340308 ns
bigg1select 4/4 keys463.241990 ns
bigg1fast select 4/4 keys56.175028 ns
bigparallelassoc to map32.371441 ns
bigparallelassoc to record19.345769 ns
bigparallelfast-assoc to map30.053994 ns
bigparallelfast-assoc to record16.126589 ns
bigparallelassoc-in 149.492236 ns
bigparallelassoc-in 269.415102 ns
bigparallelassoc-in 3167.128542 ns
bigparallelassoc-in 4189.282406 ns
bigparallelinline-assoc-in 127.377661 ns
bigparallelinline-assoc-in 2106.761482 ns
bigparallelinline-assoc-in 3112.802275 ns
bigparallelinline-assoc-in 4121.005657 ns
bigparallelupdate-in 1134.903868 ns
bigparallelinline-update-in 1135.611914 ns
bigparallelupdate-in 2193.789099 ns
bigparallelinline-update-in 2154.667823 ns
bigparallelupdate-in 3235.722744 ns
bigparallelinline-update-in 3184.080886 ns
bigparallelupdate-in 4280.051438 ns
bigparallelinline-update-in 4214.153675 ns
bigparallelget from map10.338142 ns
bigparallelmap on keyword8.876696 ns
bigparallelkeyword on map9.502878 ns
bigparallelget from record14.311665 ns
bigparallelkeyword on record6.190041 ns
bigparallel.get from record11.535257 ns
bigparallelget field from record3.636666 ns
bigparallelget from fast-map34.894720 ns
bigparallelfast-get from fast-map7.051884 ns
bigparallelmerge maps333.429777 ns
bigparallelfast merge maps226.055813 ns
bigparallelmerge 2 maps362.941200 ns
bigparallelinline merge 2 maps281.370760 ns
bigparallelinline fast merge 2 maps227.559517 ns
bigparallelmerge 3 maps1.176878 µs
bigparallelinline merge 3 maps1.049544 µs
bigparallelinline fast merge 3 maps997.989050 ns
bigparallelmerge 4 maps1.476614 µs
bigparallelinline merge 4 maps1.280925 µs
bigparallelinline fast merge 4 maps1.256592 µs
bigparallelget-in 139.999427 ns
bigparallelfast get-in 110.316292 ns
bigparallelget some in 15.910026 ns
bigparallelget-in 251.284549 ns
bigparallelfast get-in 217.784598 ns
bigparallelget some in 210.200495 ns
bigparallelget-in 368.618918 ns
bigparallelfast get-in 325.367662 ns
bigparallelget some in 313.067672 ns
bigparallelget-in 482.598429 ns
bigparallelfast get-in 419.698458 ns
bigparallelget some in 417.315701 ns
bigparallelselect 1/4 keys172.930122 ns
bigparallelfast select 1/4 keys11.368870 ns
bigparallelselect 2/4 keys213.377422 ns
bigparallelfast select 2/4 keys16.799935 ns
bigparallelselect 3/4 keys274.118673 ns
bigparallelfast select 3/4 keys24.881389 ns
bigparallelselect 4/4 keys312.094822 ns
bigparallelfast select 4/4 keys34.382155 ns
medg1assoc to map48.017200 ns
medg1assoc to record20.643270 ns
medg1fast-assoc to map46.291795 ns
medg1fast-assoc to record25.650662 ns
medg1assoc-in 143.117304 ns
medg1assoc-in 267.682634 ns
medg1assoc-in 3172.921140 ns
medg1assoc-in 4198.950834 ns
medg1inline-assoc-in 122.610115 ns
medg1inline-assoc-in 231.903842 ns
medg1inline-assoc-in 342.472088 ns
medg1inline-assoc-in 450.987722 ns
medg1update-in 1140.507125 ns
medg1inline-update-in 1139.058500 ns
medg1update-in 2203.525480 ns
medg1inline-update-in 2153.105318 ns
medg1update-in 3240.717953 ns
medg1inline-update-in 3174.664928 ns
medg1update-in 4276.727790 ns
medg1inline-update-in 4199.965659 ns
medg1get from map8.834362 ns
medg1map on keyword5.912481 ns
medg1keyword on map7.808933 ns
medg1get from record11.003575 ns
medg1keyword on record3.749699 ns
medg1.get from record8.644511 ns
medg1get field from record2.704952 ns
medg1get from fast-map35.390073 ns
medg1fast-get from fast-map6.566297 ns
medg1merge maps447.927732 ns
medg1fast merge maps324.039570 ns
medg1merge 2 maps487.202800 ns
medg1inline merge 2 maps408.914161 ns
medg1inline fast merge 2 maps322.729569 ns
medg1merge 3 maps1.667746 µs
medg1inline merge 3 maps1.512118 µs
medg1inline fast merge 3 maps1.436334 µs
medg1merge 4 maps1.993162 µs
medg1inline merge 4 maps1.815098 µs
medg1inline fast merge 4 maps1.804004 µs
medg1get-in 134.169670 ns
medg1fast get-in 15.289748 ns
medg1get some in 14.243272 ns
medg1get-in 248.283999 ns
medg1fast get-in 28.627374 ns
medg1get some in 27.429364 ns
medg1get-in 366.763657 ns
medg1fast get-in 311.984588 ns
medg1get some in 39.202201 ns
medg1get-in 479.162261 ns
medg1fast get-in 414.872275 ns
medg1get some in 411.299371 ns
medg1select 1/4 keys176.967376 ns
medg1fast select 1/4 keys11.581138 ns
medg1select 2/4 keys255.269173 ns
medg1fast select 2/4 keys17.749808 ns
medg1select 3/4 keys332.351710 ns
medg1fast select 3/4 keys27.370380 ns
medg1select 4/4 keys409.945355 ns
medg1fast select 4/4 keys35.948932 ns
medparallelassoc to map32.652118 ns
medparallelassoc to record20.071973 ns
medparallelfast-assoc to map30.042532 ns
medparallelfast-assoc to record15.483539 ns
medparallelassoc-in 149.995857 ns
medparallelassoc-in 271.163329 ns
medparallelassoc-in 3163.669857 ns
medparallelassoc-in 4182.472549 ns
medparallelinline-assoc-in 128.230009 ns
medparallelinline-assoc-in 2105.898229 ns
medparallelinline-assoc-in 3114.227061 ns
medparallelinline-assoc-in 4121.748115 ns
medparallelupdate-in 1146.082382 ns
medparallelinline-update-in 1139.446354 ns
medparallelupdate-in 2206.589125 ns
medparallelinline-update-in 2155.998110 ns
medparallelupdate-in 3246.369180 ns
medparallelinline-update-in 3186.458825 ns
medparallelupdate-in 4290.608633 ns
medparallelinline-update-in 4221.029629 ns
medparallelget from map10.214164 ns
medparallelmap on keyword7.584589 ns
medparallelkeyword on map10.197128 ns
medparallelget from record13.653376 ns
medparallelkeyword on record5.386355 ns
medparallel.get from record11.545223 ns
medparallelget field from record2.887781 ns
medparallelget from fast-map34.650105 ns
medparallelfast-get from fast-map8.487544 ns
medparallelmerge maps347.013400 ns
medparallelfast merge maps226.685897 ns
medparallelmerge 2 maps362.919701 ns
medparallelinline merge 2 maps293.498301 ns
medparallelinline fast merge 2 maps223.999555 ns
medparallelmerge 3 maps1.191610 µs
medparallelinline merge 3 maps1.060675 µs
medparallelinline fast merge 3 maps1.028475 µs
medparallelmerge 4 maps1.481805 µs
medparallelinline merge 4 maps1.267463 µs
medparallelinline fast merge 4 maps1.299272 µs
medparallelget-in 143.327491 ns
medparallelfast get-in 19.256784 ns
medparallelget some in 15.114690 ns
medparallelget-in 251.754609 ns
medparallelfast get-in 217.045797 ns
medparallelget some in 29.199258 ns
medparallelget-in 367.543169 ns
medparallelfast get-in 323.886607 ns
medparallelget some in 311.760107 ns
medparallelget-in 481.026015 ns
medparallelfast get-in 430.731871 ns
medparallelget some in 416.774926 ns
medparallelselect 1/4 keys165.262113 ns
medparallelfast select 1/4 keys10.629346 ns
medparallelselect 2/4 keys215.158509 ns
medparallelfast select 2/4 keys16.485982 ns
medparallelselect 3/4 keys261.335112 ns
medparallelfast select 3/4 keys25.094703 ns
medparallelselect 4/4 keys319.062781 ns
medparallelfast select 4/4 keys33.688716 ns
smallg1assoc to map47.666145 ns
smallg1assoc to record24.798200 ns
smallg1fast-assoc to map45.433991 ns
smallg1fast-assoc to record26.473440 ns
smallg1assoc-in 157.366398 ns
smallg1assoc-in 2161.849693 ns
smallg1assoc-in 3193.376447 ns
smallg1assoc-in 4216.236068 ns
smallg1inline-assoc-in 134.896216 ns
smallg1inline-assoc-in 244.813208 ns
smallg1inline-assoc-in 353.825374 ns
smallg1inline-assoc-in 463.011021 ns
smallg1update-in 1152.824818 ns
smallg1inline-update-in 1146.139102 ns
smallg1update-in 2220.670602 ns
smallg1inline-update-in 2178.283010 ns
smallg1update-in 3272.357914 ns
smallg1inline-update-in 3210.222583 ns
smallg1update-in 4323.837439 ns
smallg1inline-update-in 4241.690539 ns
smallg1get from map6.890287 ns
smallg1map on keyword5.983850 ns
smallg1keyword on map7.379764 ns
smallg1get from record11.147459 ns
smallg1keyword on record3.900881 ns
smallg1.get from record8.578816 ns
smallg1get field from record3.021558 ns
smallg1get from fast-map34.433630 ns
smallg1fast-get from fast-map6.437504 ns
smallg1merge maps443.831947 ns
smallg1fast merge maps322.338372 ns
smallg1merge 2 maps480.732274 ns
smallg1inline merge 2 maps397.315515 ns
smallg1inline fast merge 2 maps331.951032 ns
smallg1merge 3 maps1.625117 µs
smallg1inline merge 3 maps1.475430 µs
smallg1inline fast merge 3 maps1.434441 µs
smallg1merge 4 maps1.944576 µs
smallg1inline merge 4 maps1.729100 µs
smallg1inline fast merge 4 maps1.758550 µs
smallg1get-in 134.282855 ns
smallg1fast get-in 15.547193 ns
smallg1get some in 14.647768 ns
smallg1get-in 242.763183 ns
smallg1fast get-in 28.872948 ns
smallg1get some in 26.904743 ns
smallg1get-in 361.994779 ns
smallg1fast get-in 311.837029 ns
smallg1get some in 38.724223 ns
smallg1get-in 473.568642 ns
smallg1fast get-in 415.524171 ns
smallg1get some in 410.565953 ns
smallg1select 1/4 keys175.533348 ns
smallg1fast select 1/4 keys11.462009 ns
smallg1select 2/4 keys254.691261 ns
smallg1fast select 2/4 keys17.650708 ns
smallg1select 3/4 keys340.676613 ns
smallg1fast select 3/4 keys27.556893 ns
smallg1select 4/4 keys413.283392 ns
smallg1fast select 4/4 keys37.457283 ns
smallparallelassoc to map35.119336 ns
smallparallelassoc to record16.812822 ns
smallparallelfast-assoc to map31.005039 ns
smallparallelfast-assoc to record16.537999 ns
smallparallelassoc-in 148.362913 ns
smallparallelassoc-in 267.516749 ns
smallparallelassoc-in 3164.549447 ns
smallparallelassoc-in 4182.822911 ns
smallparallelinline-assoc-in 127.653108 ns
smallparallelinline-assoc-in 234.917387 ns
smallparallelinline-assoc-in 342.037604 ns
smallparallelinline-assoc-in 450.553205 ns
smallparallelupdate-in 1135.826912 ns
smallparallelinline-update-in 1129.139195 ns
smallparallelupdate-in 2195.473361 ns
smallparallelinline-update-in 2156.309724 ns
smallparallelupdate-in 3234.387162 ns
smallparallelinline-update-in 3179.661130 ns
smallparallelupdate-in 4276.173607 ns
smallparallelinline-update-in 4206.638998 ns
smallparallelget from map8.142737 ns
smallparallelmap on keyword6.804318 ns
smallparallelkeyword on map8.481796 ns
smallparallelget from record14.686627 ns
smallparallelkeyword on record4.603083 ns
smallparallel.get from record11.364444 ns
smallparallelget field from record3.116383 ns
smallparallelget from fast-map33.578521 ns
smallparallelfast-get from fast-map7.810883 ns
smallparallelmerge maps332.567936 ns
smallparallelfast merge maps215.901561 ns
smallparallelmerge 2 maps358.261884 ns
smallparallelinline merge 2 maps282.749681 ns
smallparallelinline fast merge 2 maps217.665055 ns
smallparallelmerge 3 maps1.173280 µs
smallparallelinline merge 3 maps1.036088 µs
smallparallelinline fast merge 3 maps993.909129 ns
smallparallelmerge 4 maps1.488247 µs
smallparallelinline merge 4 maps1.266443 µs
smallparallelinline fast merge 4 maps1.277996 µs
smallparallelget-in 135.961353 ns
smallparallelfast get-in 16.784345 ns
smallparallelget some in 15.655861 ns
smallparallelget-in 246.913183 ns
smallparallelfast get-in 211.176587 ns
smallparallelget some in 29.516190 ns
smallparallelget-in 361.262515 ns
smallparallelfast get-in 316.723093 ns
smallparallelget some in 313.619676 ns
smallparallelget-in 472.770708 ns
smallparallelfast get-in 420.918450 ns
smallparallelget some in 416.417517 ns
smallparallelselect 1/4 keys168.064962 ns
smallparallelfast select 1/4 keys11.479721 ns
smallparallelselect 2/4 keys215.831260 ns
smallparallelfast select 2/4 keys17.746165 ns
smallparallelselect 3/4 keys265.468694 ns
smallparallelfast select 3/4 keys24.542730 ns
smallparallelselect 4/4 keys312.513226 ns
smallparallelfast select 4/4 keys30.892997 ns

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close