Created
March 20, 2015 21:07
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
empty 0.960000 0.240000 1.200000 ( 0.706804) | |
empty - dup 0.820000 0.080000 0.900000 ( 0.660550) | |
1char 0.710000 0.130000 0.840000 ( 0.514980) | |
1char - dup 0.630000 0.000000 0.630000 ( 0.613213) | |
5 chars 0.930000 0.010000 0.940000 ( 0.853446) | |
5 chars - dup 1.370000 0.000000 1.370000 ( 1.107195) | |
10 chars 1.080000 0.000000 1.080000 ( 0.917764) | |
10 chars - dup 1.260000 0.030000 1.290000 ( 1.120841) | |
20 chars 1.050000 0.010000 1.060000 ( 0.972268) | |
20 chars - dup 1.490000 0.000000 1.490000 ( 1.333460) | |
---------------------------------------- total: 10.800000sec | |
user system total real | |
empty 0.550000 0.000000 0.550000 ( 0.486022) | |
empty - dup 0.880000 0.000000 0.880000 ( 0.686752) | |
1char 0.600000 0.000000 0.600000 ( 0.508257) | |
1char - dup 0.640000 0.000000 0.640000 ( 0.633246) | |
5 chars 1.140000 0.000000 1.140000 ( 0.922640) | |
5 chars - dup 1.410000 0.000000 1.410000 ( 1.157144) | |
10 chars 1.140000 0.000000 1.140000 ( 0.982482) | |
10 chars - dup 1.240000 0.000000 1.240000 ( 1.139877) | |
20 chars 1.090000 0.000000 1.090000 ( 0.994289) | |
20 chars - dup 1.440000 0.010000 1.450000 ( 1.303840) |
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
Rehearsal -------------------------------------------------- | |
empty 1.140000 0.000000 1.140000 ( 1.136569) | |
empty - dup 2.530000 0.000000 2.530000 ( 2.540167) | |
1char 1.050000 0.000000 1.050000 ( 1.051799) | |
1char - dup 2.530000 0.000000 2.530000 ( 2.523234) | |
5 chars 1.050000 0.000000 1.050000 ( 1.054948) | |
5 chars - dup 2.550000 0.000000 2.550000 ( 2.547925) | |
10 chars 1.080000 0.000000 1.080000 ( 1.082971) | |
10 chars - dup 2.570000 0.000000 2.570000 ( 2.567220) | |
20 chars 1.150000 0.000000 1.150000 ( 1.152727) | |
20 chars - dup 2.650000 0.000000 2.650000 ( 2.657810) | |
---------------------------------------- total: 18.300000sec | |
user system total real | |
empty 1.060000 0.000000 1.060000 ( 1.057698) | |
empty - dup 2.540000 0.000000 2.540000 ( 2.542187) | |
1char 1.060000 0.000000 1.060000 ( 1.057650) | |
1char - dup 2.560000 0.000000 2.560000 ( 2.560202) | |
5 chars 1.060000 0.000000 1.060000 ( 1.060847) | |
5 chars - dup 2.600000 0.000000 2.600000 ( 2.592937) | |
10 chars 1.080000 0.000000 1.080000 ( 1.089204) | |
10 chars - dup 2.580000 0.000000 2.580000 ( 2.587015) | |
20 chars 1.150000 0.000000 1.150000 ( 1.150635) | |
20 chars - dup 2.640000 0.000000 2.640000 ( 2.634209 |
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
``` | |
str0 = "" | |
str1 = "a" | |
str2 = "abcde" | |
str3 = str2 * 2 | |
str4 = str3 * 2 | |
require 'benchmark' | |
CYCLES = 10_000_000 | |
Benchmark.bmbm do |x| | |
x.report("empty") { CYCLES.times { str0.reverse } } | |
x.report("empty - dup") { CYCLES.times { str0.dup.reverse! } } | |
x.report("1char") { CYCLES.times { str1.reverse } } | |
x.report("1char - dup") { CYCLES.times { str1.dup.reverse! } } | |
x.report("5 chars") { CYCLES.times { str2.reverse } } | |
x.report("5 chars - dup") { CYCLES.times { str2.dup.reverse! } } | |
x.report("10 chars") { CYCLES.times { str3.reverse } } | |
x.report("10 chars - dup") { CYCLES.times { str3.dup.reverse! } } | |
x.report("20 chars") { CYCLES.times { str4.reverse } } | |
x.report("20 chars - dup") { CYCLES.times { str4.dup.reverse! } } | |
end | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment