Skip to content

Instantly share code, notes, and snippets.

@agrimm
Created August 3, 2013 02:05
Show Gist options
  • Save agrimm/6144794 to your computer and use it in GitHub Desktop.
Save agrimm/6144794 to your computer and use it in GitHub Desktop.
Benchmarking of String#delete and String#tr on Rubinius and MRI using Rubinius' benchmark code
$ uname -a
Darwin [redacted] 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$ ruby --version
rubinius 2.0.0.n215 (1.9.3 0849828f 2013-08-03 JI) [x86_64-apple-darwin10.8.0]
$ bin/benchmark --target r benchmark/core/string/bench_delete.rb
=== ruby ===
Empty string delete! 544648.6 (±0.7%) i/s - 2733378 in 5.018887s (cycle=23977)
Long string delete! with empty argument
8720.7 (±2.3%) i/s - 44000 in 5.048465s (cycle=800)
Long string delete! with non match
8665.7 (±1.9%) i/s - 43904 in 5.068472s (cycle=784)
Long string delete! with match
13123.1 (±1.0%) i/s - 65615 in 5.000482s (cycle=1193)
Huge string delete! with empty argument
8.1 (±0.0%) i/s - 41 in 5.083104s (cycle=1)
Huge string delete! with non match
8.1 (±0.0%) i/s - 41 in 5.087086s (cycle=1)
Huge string delete! with match
12.9 (±0.0%) i/s - 65 in 5.035324s (cycle=1)
Empty string delete 490889.9 (±1.3%) i/s - 2469933 in 5.032542s (cycle=30493)
$ bin/benchmark --target r benchmark/core/string/bench_tr.rb
=== ruby ===
Empty string tr! 439106.0 (±0.9%) i/s - 2200000 in 5.010629s (cycle=17600)
Medium string tr! with empty arguments
71723.9 (±1.2%) i/s - 359464 in 5.012466s (cycle=6419)
Medium string tr! with non match
37008.1 (±1.4%) i/s - 185614 in 5.016581s (cycle=3146)
Medium string tr! with match
5011.3 (±1.9%) i/s - 25200 in 5.030537s (cycle=360)
Medium string tr! with a long from_str
4755.4 (±3.1%) i/s - 23766 in 5.003597s (cycle=466)
Medium string tr! with a long non matching from_str
57733.8 (±2.6%) i/s - 288408 in 4.999672s (cycle=4728)
Long string tr! with empty arguments
8588.5 (±0.9%) i/s - 43707 in 5.089496s (cycle=857)
Long string tr! with non match
4204.4 (±1.2%) i/s - 21165 in 5.034696s (cycle=415)
Long string tr! with match
122.9 (±0.8%) i/s - 624 in 5.076925s (cycle=12)
Long string tr! with a long from_str
123.1 (±0.8%) i/s - 624 in 5.067661s (cycle=12)
Long string tr! with a long non matching from_str
8385.3 (±1.2%) i/s - 42687 in 5.091500s (cycle=837)
Empty string tr 425751.1 (±1.0%) i/s - 2139164 in 5.024929s (cycle=24874)
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin10.8.0]
$ bin/benchmark --target r benchmark/core/string/bench_delete.rb
=== ruby ===
Empty string delete! 2689389.5 (±3.1%) i/s - 13447226 in 5.005897s (cycle=67574)
Long string delete! with empty argument
167854.3 (±3.6%) i/s - 844285 in 5.036253s (cycle=12989)
Long string delete! with non match
166098.6 (±4.3%) i/s - 835770 in 5.041591s (cycle=12858)
Long string delete! with match
236891.0 (±2.0%) i/s - 1185203 in 5.005154s (cycle=16693)
Huge string delete! with empty argument
235.8 (±3.4%) i/s - 1196 in 5.077594s (cycle=23)
Huge string delete! with non match
223.7 (±5.8%) i/s - 1122 in 5.035159s (cycle=22)
Huge string delete! with match
407.0 (±1.5%) i/s - 2040 in 5.012839s (cycle=40)
Empty string delete 5828576.0 (±4.3%) i/s - 29067868 in 4.998667s (cycle=79204)
$ bin/benchmark --target r benchmark/core/string/bench_tr.rb
=== ruby ===
Empty string tr! 2562335.9 (±2.6%) i/s - 12844468 in 5.016828s (cycle=65533)
Medium string tr! with empty arguments
602978.2 (±4.0%) i/s - 3020600 in 5.017684s (cycle=34325)
Medium string tr! with non match
738441.6 (±4.6%) i/s - 3706752 in 5.030952s (cycle=37824)
Medium string tr! with match
708790.4 (±4.1%) i/s - 3554080 in 5.022608s (cycle=36640)
Medium string tr! with a long from_str
513521.5 (±3.5%) i/s - 2565032 in 5.000990s (cycle=30904)
Medium string tr! with a long non matching from_str
523037.0 (±3.1%) i/s - 2637852 in 5.048163s (cycle=31403)
Long string tr! with empty arguments
171039.6 (±4.3%) i/s - 854896 in 5.007490s (cycle=12572)
Long string tr! with non match
182388.7 (±3.3%) i/s - 917631 in 5.036479s (cycle=13299)
Long string tr! with match
161643.0 (±3.8%) i/s - 816684 in 5.059639s (cycle=12374)
Long string tr! with a long from_str
149637.6 (±4.2%) i/s - 753675 in 5.045669s (cycle=11595)
Long string tr! with a long non matching from_str
164289.9 (±3.9%) i/s - 825574 in 5.032716s (cycle=12322)
Empty string tr 5675181.4 (±4.0%) i/s - 28385462 in 5.011226s (cycle=79289)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment