Skip to content

Instantly share code, notes, and snippets.

@agrimm
Created August 3, 2013 02:10
Show Gist options
  • Save agrimm/6144809 to your computer and use it in GitHub Desktop.
Save agrimm/6144809 to your computer and use it in GitHub Desktop.
Running ordinary benchmark program for String#delete, String#tr, and String#gsub
# Based on https://gist.github.com/agrimm/6144794 , but running it with TIMES = 1_000_000
$ ruby --version; time ruby delete-tr.rb ; rbenv shell 2.0.0-p247 ; ruby --version; time ruby delete-tr.rb
rubinius 2.0.0.n213 (1.9.3 c7f6ce0a 2013-08-01 JI) [x86_64-apple-darwin10.8.0]
Rehearsal ----------------------------------------------------
delete 238.547355 0.441726 238.989081 (239.530814)
tr 239.829005 0.381523 240.210528 (240.779957)
gsub with regexp 1267.507984 7.022022 1274.530006 (1288.916921)
gsub with string 1307.494479 8.922239 1316.416718 (1353.190891)
---------------------------------------- total: 3070.146333sec
user system total real
delete 238.610717 0.622618 239.233335 (245.259406)
tr 241.016633 0.740512 241.757145 (249.270124)
gsub with regexp 1298.327615 9.350199 1307.677814 (1357.085734)
gsub with string 1298.666943 9.370118 1308.037061 (1354.205581)
real 105m28.826s
user 102m23.508s
sys 0m45.325s
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin10.8.0]
Rehearsal ----------------------------------------------------
delete 65.950000 1.160000 67.110000 ( 67.581271)
tr 66.080000 1.050000 67.130000 ( 69.170526)
gsub with regexp 998.840000 1.930000 1000.770000 (1014.215939)
gsub with string 1009.230000 1.810000 1011.040000 (1025.894625)
---------------------------------------- total: 2146.050000sec
user system total real
delete 66.000000 1.180000 67.180000 ( 68.054589)
tr 66.100000 1.290000 67.390000 ( 67.765937)
gsub with regexp 970.130000 1.920000 972.050000 (976.706647)
gsub with string 974.170000 1.390000 975.560000 (978.344746)
real 71m7.950s
user 70m16.549s
sys 0m11.773s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment