Skip to content

Instantly share code, notes, and snippets.

@shugo
Last active November 9, 2019 00:58
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 shugo/fba0154608d223a0e813b544c37dcdb2 to your computer and use it in GitHub Desktop.
Save shugo/fba0154608d223a0e813b544c37dcdb2 to your computer and use it in GitHub Desktop.
Benchmark results of Immutable::Map

Original

Rehearsal ---------------------------------------------------------
Hash aset               0.028307   0.003103   0.031410 (  0.031495)
Hash aref               0.010025   0.000005   0.010030 (  0.010047)
Hash delete             0.012342   0.000065   0.012407 (  0.012558)
AVLTree aset            0.528481   0.002488   0.530969 (  0.531534)
AVLTree aref            0.159875   0.000126   0.160001 (  0.160148)
AVLTree delete          0.575293   0.002389   0.577682 (  0.578515)
RedBlackTree aset       0.682724   0.001943   0.684667 (  0.685771)
RedBlackTree aref       0.207767   0.001522   0.209289 (  0.211077)
RedBlackTree delete     0.473064   0.001281   0.474345 (  0.475184)
Immutable::Map insert   1.118944   0.004264   1.123208 (  1.123962)
Immutable::Map aref     0.155557   0.000367   0.155924 (  0.156220)
Immutable::Map delete   1.660851   0.002574   1.663425 (  1.664582)
------------------------------------------------ total: 5.633357sec

                            user     system      total        real
Hash aset               0.025550   0.000805   0.026355 (  0.026406)
Hash aref               0.010828   0.000024   0.010852 (  0.010880)
Hash delete             0.011232   0.000013   0.011245 (  0.011261)
AVLTree aset            0.465752   0.000532   0.466284 (  0.466859)
AVLTree aref            0.154698   0.000128   0.154826 (  0.154990)
AVLTree delete          0.506981   0.000373   0.507354 (  0.507784)
RedBlackTree aset       0.588323   0.000517   0.588840 (  0.589620)
RedBlackTree aref       0.167014   0.000246   0.167260 (  0.167535)
RedBlackTree delete     0.414867   0.000605   0.415472 (  0.415922)
Immutable::Map insert   1.027089   0.001353   1.028442 (  1.029295)
Immutable::Map aref     0.154790   0.000060   0.154850 (  0.154980)
Immutable::Map delete   1.606364   0.005860   1.612224 (  1.614171)

Pattern matching

/Users/shugo/src/immutable/lib/immutable/map.rb:228: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!
Rehearsal ---------------------------------------------------------
Hash aset               0.031053   0.003382   0.034435 (  0.035008)
Hash aref               0.010886   0.000025   0.010911 (  0.010969)
Hash delete             0.011744   0.000024   0.011768 (  0.011840)
AVLTree aset            0.501500   0.002750   0.504250 (  0.506571)
AVLTree aref            0.160304   0.000225   0.160529 (  0.160934)
AVLTree delete          0.577906   0.003886   0.581792 (  0.584579)
RedBlackTree aset       0.581837   0.000953   0.582790 (  0.583397)
RedBlackTree aref       0.165056   0.000367   0.165423 (  0.165779)
RedBlackTree delete     0.475471   0.001276   0.476747 (  0.477249)
Immutable::Map insert   2.279682   0.005531   2.285213 (  2.288831)
Immutable::Map aref     0.160681   0.000827   0.161508 (  0.162360)
Immutable::Map delete   1.839120   0.003387   1.842507 (  1.843882)
------------------------------------------------ total: 6.817873sec

                            user     system      total        real
Hash aset               0.025527   0.000792   0.026319 (  0.026370)
Hash aref               0.010441   0.000022   0.010463 (  0.010480)
Hash delete             0.011143   0.000020   0.011163 (  0.011188)
AVLTree aset            0.464922   0.000476   0.465398 (  0.465753)
AVLTree aref            0.159777   0.000133   0.159910 (  0.160074)
AVLTree delete          0.499994   0.000469   0.500463 (  0.501194)
RedBlackTree aset       0.571900   0.000372   0.572272 (  0.572669)
RedBlackTree aref       0.163706   0.000246   0.163952 (  0.164216)
RedBlackTree delete     0.413739   0.000702   0.414441 (  0.415321)
Immutable::Map insert   2.228300   0.003725   2.232025 (  2.237947)
Immutable::Map aref     0.162824   0.000114   0.162938 (  0.163114)
Immutable::Map delete   1.795947   0.006065   1.802012 (  1.809544)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment