Last active
November 24, 2019 21:51
-
-
Save eregon/15ebe02ff8f42c0ab964e1066a783f9d to your computer and use it in GitHub Desktop.
This file contains 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
# Using a custom #measure method to minimize overhead and code loaded | |
def measure | |
t0 = Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :nanosecond) | |
yield | |
t1 = Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :nanosecond) | |
puts (t1-t0)/1e9 | |
end | |
def req(x) | |
x | |
end | |
def kw(x, kw: 1) | |
x | |
end | |
def kwrest(x, **kw) | |
x | |
end | |
N = 10_000_000 | |
R = 5 | |
hash = {a: 1} | |
arr = [hash] | |
puts 'baseline' | |
R.times do | |
measure { N.times { req(1) } } | |
end | |
puts 'req(*arr)' | |
R.times do | |
measure { N.times { req(*arr) } } | |
end | |
puts 'kw(*arr)' | |
R.times do | |
measure { N.times { kw(*arr) } } | |
end | |
puts 'kwrest(*arr)' | |
R.times do | |
measure { N.times { kwrest(*arr) } } | |
end |
This file contains 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
$ ruby -v | |
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux] | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.556498739 | |
0.56321874 | |
0.562705704 | |
0.56286869 | |
0.562649733 | |
req(*arr) | |
0.716321519 | |
0.694904555 | |
0.694573324 | |
0.694576273 | |
0.694596222 | |
kw(*arr) | |
0.947158229 | |
0.957557503 | |
0.957743827 | |
0.957672197 | |
0.957757722 | |
kwrest(*arr) | |
0.97981769 | |
0.971274875 | |
0.971213895 | |
0.972323403 | |
0.97139911 | |
ruby --disable-gems bench/micro/kwargs.rb 15.95s user 0.00s system 99% cpu 15.978 total | |
baseline | |
0.543503567 | |
0.579074212 | |
0.579188671 | |
0.579152884 | |
0.579290279 | |
req(*arr) | |
0.680170764 | |
0.695272739 | |
0.696134563 | |
0.69565114 | |
0.693645885 | |
kw(*arr) | |
0.930668173 | |
0.936309911 | |
0.936998048 | |
0.936488036 | |
0.936350557 | |
kwrest(*arr) | |
0.962054807 | |
0.968107834 | |
0.965702884 | |
0.968630287 | |
0.970068498 | |
ruby --disable-gems bench/micro/kwargs.rb 15.84s user 0.00s system 99% cpu 15.866 total | |
baseline | |
0.600405021 | |
0.549232734 | |
0.549165863 | |
0.549389403 | |
0.549059959 | |
req(*arr) | |
0.760612857 | |
0.687938265 | |
0.687430322 | |
0.68832802 | |
0.689098228 | |
kw(*arr) | |
0.999438754 | |
0.927062979 | |
0.928765576 | |
0.925783708 | |
0.92627865 | |
kwrest(*arr) | |
1.018479864 | |
0.973268431 | |
0.972853228 | |
0.974264476 | |
0.973758511 | |
ruby --disable-gems bench/micro/kwargs.rb 15.93s user 0.00s system 99% cpu 15.966 total | |
$ ruby -v | |
ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux] | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.61620553 | |
0.552478661 | |
0.552750217 | |
0.552461592 | |
0.552425983 | |
req(*arr) | |
0.75846297 | |
0.763787479 | |
0.763900723 | |
0.764693452 | |
0.763899259 | |
kw(*arr) | |
1.022046847 | |
1.022146628 | |
1.022251514 | |
1.022320842 | |
1.022253857 | |
kwrest(*arr) | |
1.063251137 | |
1.072118722 | |
1.071812686 | |
1.07211827 | |
1.071629874 | |
ruby --disable-gems bench/micro/kwargs.rb 17.11s user 0.00s system 99% cpu 17.135 total | |
baseline | |
0.546925873 | |
0.575672019 | |
0.575645041 | |
0.575556696 | |
0.575591012 | |
req(*arr) | |
0.750946111 | |
0.781332168 | |
0.781428285 | |
0.781455906 | |
0.781308894 | |
kw(*arr) | |
1.017885258 | |
1.043840463 | |
1.044430862 | |
1.043844008 | |
1.04368146 | |
kwrest(*arr) | |
1.057231789 | |
1.079443075 | |
1.079646256 | |
1.079265938 | |
1.079339089 | |
ruby --disable-gems bench/micro/kwargs.rb 17.30s user 0.00s system 99% cpu 17.327 total | |
baseline | |
0.542229326 | |
0.541851474 | |
0.541874574 | |
0.541841068 | |
0.541854775 | |
req(*arr) | |
0.756813773 | |
0.761808028 | |
0.76189366 | |
0.761875683 | |
0.76190478 | |
kw(*arr) | |
1.019009544 | |
1.016138798 | |
1.016062619 | |
1.0161038 | |
1.016030474 | |
kwrest(*arr) | |
1.053915297 | |
1.052211754 | |
1.051505006 | |
1.050861654 | |
1.051708982 | |
ruby --disable-gems bench/micro/kwargs.rb 16.86s user 0.00s system 99% cpu 16.889 total |
This file contains 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
$ ruby -v | |
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux] | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.57038803 | |
0.579239346 | |
0.57910095 | |
0.579105875 | |
0.579171497 | |
req(*arr) | |
0.69100269 | |
0.713866062 | |
0.714013764 | |
0.713814586 | |
0.713823516 | |
kw(*arr) | |
0.942095659 | |
0.949155492 | |
0.948649517 | |
0.948586077 | |
0.948608679 | |
kwrest(*arr) | |
0.984515066 | |
0.998077986 | |
0.998113534 | |
0.998325614 | |
0.998381101 | |
ruby --disable-gems bench/micro/kwargs.rb 16.15s user 0.00s system 99% cpu 16.180 total | |
baseline | |
0.589958358 | |
0.593847837 | |
0.594297645 | |
0.593064425 | |
0.592895917 | |
req(*arr) | |
0.695859621 | |
0.698130228 | |
0.698130814 | |
0.698129321 | |
0.698155101 | |
kw(*arr) | |
0.920279495 | |
0.921479766 | |
0.921444683 | |
0.921479473 | |
0.921443387 | |
kwrest(*arr) | |
0.971525937 | |
0.964219101 | |
0.964216301 | |
0.964255305 | |
0.963947626 | |
ruby --disable-gems bench/micro/kwargs.rb 15.88s user 0.02s system 99% cpu 15.928 total | |
baseline | |
0.553985372 | |
0.554001637 | |
0.55391866 | |
0.553948758 | |
0.554013021 | |
req(*arr) | |
0.699570447 | |
0.681016161 | |
0.681010485 | |
0.680707584 | |
0.6814361 | |
kw(*arr) | |
0.92722361 | |
0.928044891 | |
0.928217066 | |
0.928046681 | |
0.928192838 | |
kwrest(*arr) | |
0.963378432 | |
0.963142081 | |
0.96322044 | |
0.96773012 | |
0.967242716 | |
ruby --disable-gems bench/micro/kwargs.rb 15.66s user 0.00s system 99% cpu 15.689 total | |
$ chruby trunk | |
$ ruby -v | |
ruby 2.7.0dev (2019-11-24T14:29:09Z master 1aeb201d28) [x86_64-linux] | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.54831052 | |
0.540292787 | |
0.540406342 | |
0.540155288 | |
0.540361773 | |
req(*arr) | |
0.755093071 | |
0.744183953 | |
0.744092932 | |
0.744113376 | |
0.744090845 | |
kw(*arr) | |
0.999324673 | |
0.993234927 | |
0.993202728 | |
0.993116784 | |
0.994466792 | |
kwrest(*arr) | |
1.055565028 | |
1.056697251 | |
1.056939662 | |
1.056496525 | |
1.056267226 | |
ruby --disable-gems bench/micro/kwargs.rb 16.70s user 0.00s system 99% cpu 16.731 total | |
baseline | |
0.543270273 | |
0.541210939 | |
0.541076275 | |
0.541170976 | |
0.541352926 | |
req(*arr) | |
0.746677418 | |
0.741390673 | |
0.74135753 | |
0.741172783 | |
0.74117895 | |
kw(*arr) | |
0.99607527 | |
0.994033422 | |
0.994082389 | |
0.994049417 | |
0.993996379 | |
kwrest(*arr) | |
1.067207673 | |
1.068929024 | |
1.068751427 | |
1.069087114 | |
1.068695654 | |
ruby --disable-gems bench/micro/kwargs.rb 16.74s user 0.00s system 99% cpu 16.767 total | |
baseline | |
0.539991919 | |
0.540153448 | |
0.539961539 | |
0.54000855 | |
0.540162279 | |
req(*arr) | |
0.745011711 | |
0.780024312 | |
0.780045449 | |
0.78056356 | |
0.779945869 | |
kw(*arr) | |
0.992827841 | |
1.006676049 | |
1.006755873 | |
1.00679367 | |
1.006648232 | |
kwrest(*arr) | |
1.052326374 | |
1.062340054 | |
1.062516818 | |
1.063232802 | |
1.062352173 | |
ruby --disable-gems bench/micro/kwargs.rb 16.89s user 0.00s system 99% cpu 16.920 total |
This file contains 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
With R=10 | |
Current master, without ruby2_keywords: | |
$ ruby -v | |
truffleruby 20.0.0-dev-e4d5dfa3, like ruby 2.6.2, GraalVM CE JVM [x86_64-linux] | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.463437035 | |
0.008619721 | |
0.008785349 | |
0.00818364 | |
0.007820041 | |
0.008223483 | |
0.007949366 | |
0.007844551 | |
0.009441897 | |
0.008451774 | |
req(*arr) | |
0.579778692 | |
0.311906917 | |
0.333650945 | |
0.344218377 | |
0.298183218 | |
0.349810303 | |
0.29771344 | |
0.336059658 | |
0.296716412 | |
0.297864957 | |
kw(*arr) | |
0.477329749 | |
0.286710446 | |
0.329717326 | |
0.287255702 | |
0.279602018 | |
0.279508301 | |
0.318583715 | |
0.284971617 | |
0.279815417 | |
0.305362874 | |
kwrest(*arr) | |
0.427593045 | |
0.294506823 | |
0.305454411 | |
0.281349543 | |
0.281475889 | |
0.281532187 | |
0.306979001 | |
0.281899933 | |
0.281758751 | |
0.281175192 | |
ruby --disable-gems bench/micro/kwargs.rb 33.22s user 0.81s system 237% cpu 14.343 total | |
baseline | |
0.412231417 | |
0.008021006 | |
0.009305297 | |
0.007688376 | |
0.00797362 | |
0.008922343 | |
0.00824351 | |
0.007836645 | |
0.007902696 | |
0.009731062 | |
req(*arr) | |
0.531433094 | |
0.319783689 | |
0.326181521 | |
0.305065373 | |
0.319876049 | |
0.322734948 | |
0.295905692 | |
0.321355289 | |
0.31392339 | |
0.300149209 | |
kw(*arr) | |
0.425699933 | |
0.30234801 | |
0.322353806 | |
0.285531643 | |
0.297372249 | |
0.290293938 | |
0.290376718 | |
0.280131682 | |
0.289551619 | |
0.281536455 | |
kwrest(*arr) | |
0.432190122 | |
0.292667965 | |
0.300214378 | |
0.280087333 | |
0.280183149 | |
0.289103909 | |
0.28027156 | |
0.288915871 | |
0.28054284 | |
0.289026141 | |
ruby --disable-gems bench/micro/kwargs.rb 32.13s user 0.64s system 231% cpu 14.160 total | |
baseline | |
0.498430805 | |
0.007861637 | |
0.00913743 | |
0.008634662 | |
0.00787516 | |
0.007772768 | |
0.007734948 | |
0.007911675 | |
0.007951265 | |
0.009538238 | |
req(*arr) | |
0.53155985 | |
0.320288702 | |
0.317635446 | |
0.330563798 | |
0.303157317 | |
0.335160224 | |
0.332531148 | |
0.299251996 | |
0.322852003 | |
0.305804318 | |
kw(*arr) | |
0.438276845 | |
0.289182615 | |
0.300765312 | |
0.280407853 | |
0.293190503 | |
0.280550708 | |
0.290742194 | |
0.280062072 | |
0.280114635 | |
0.29147614 | |
kwrest(*arr) | |
0.415399361 | |
0.314668853 | |
0.292753463 | |
0.290059145 | |
0.299001395 | |
0.279758164 | |
0.289134553 | |
0.280050251 | |
0.289646751 | |
0.279987553 | |
ruby --disable-gems bench/micro/kwargs.rb 32.85s user 0.66s system 234% cpu 14.288 total | |
Current master, WITH ruby2_keywords checks: | |
Diff: https://github.com/oracle/truffleruby/commit/d143af3626aae009e2414bfe61833565fe3a0476 | |
$ for i in 1 2 3; do ruby --disable-gems bench/micro/kwargs.rb; done | |
baseline | |
0.412220048 | |
0.007583409 | |
0.008296852 | |
0.008481642 | |
0.007568056 | |
0.007807983 | |
0.007732074 | |
0.007636336 | |
0.008982042 | |
0.008826061 | |
req(*arr) | |
0.568208556 | |
0.334024371 | |
0.333851187 | |
0.342959378 | |
0.344415472 | |
0.31940789 | |
0.348594432 | |
0.337404004 | |
0.324404504 | |
0.338510035 | |
kw(*arr) | |
0.442439936 | |
0.333441211 | |
0.318821349 | |
0.324165586 | |
0.309944704 | |
0.309881764 | |
0.320237268 | |
0.309952203 | |
0.319149281 | |
0.310258021 | |
kwrest(*arr) | |
0.448833264 | |
0.318310332 | |
0.325054157 | |
0.311498328 | |
0.309870749 | |
0.317924062 | |
0.323476403 | |
0.310531638 | |
0.317517029 | |
0.309663936 | |
ruby --disable-gems bench/micro/kwargs.rb 33.51s user 0.70s system 226% cpu 15.077 total | |
baseline | |
0.390028009 | |
0.007525779 | |
0.007512779 | |
0.008190925 | |
0.007520599 | |
0.007483249 | |
0.007503866 | |
0.007823522 | |
0.009595703 | |
0.00772402 | |
req(*arr) | |
0.694155062 | |
0.34519069 | |
0.340953701 | |
0.353746908 | |
0.34651927 | |
0.318630544 | |
0.343834156 | |
0.318557624 | |
0.335074641 | |
0.318379153 | |
kw(*arr) | |
0.457682512 | |
0.334831882 | |
0.317878451 | |
0.324335267 | |
0.315134515 | |
0.323049402 | |
0.311942696 | |
0.312340955 | |
0.322076347 | |
0.312515672 | |
kwrest(*arr) | |
0.464346728 | |
0.318647972 | |
0.328202676 | |
0.31004449 | |
0.317919761 | |
0.31281893 | |
0.313108144 | |
0.320932159 | |
0.313359049 | |
0.318429713 | |
ruby --disable-gems bench/micro/kwargs.rb 34.95s user 0.65s system 232% cpu 15.299 total | |
baseline | |
0.474859317 | |
0.009966397 | |
0.00890715 | |
0.00942302 | |
0.007814091 | |
0.00764962 | |
0.009609255 | |
0.007650908 | |
0.008012982 | |
0.007948749 | |
req(*arr) | |
0.770499246 | |
0.370704792 | |
0.358487827 | |
0.324071554 | |
0.347919717 | |
0.319693124 | |
0.345490207 | |
0.3330284 | |
0.334323889 | |
0.319746676 | |
kw(*arr) | |
0.460773443 | |
0.328042519 | |
0.345029641 | |
0.312106761 | |
0.329944254 | |
0.313252553 | |
0.31014671 | |
0.325173445 | |
0.310029118 | |
0.321654763 | |
kwrest(*arr) | |
0.454305943 | |
0.317862639 | |
0.327644077 | |
0.309016353 | |
0.309984439 | |
0.321475695 | |
0.310739184 | |
0.320868732 | |
0.310632748 | |
0.310380622 | |
ruby --disable-gems bench/micro/kwargs.rb 35.92s user 0.74s system 239% cpu 15.288 total |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Taking the last measurement for each.
2.6.5 vs trunk
2.6.5 vs 2.7.0preview3
TruffleRuby vs TruffleRuby with ruby2_keywords check
Diff: oracle/truffleruby@d143af3