Created
May 27, 2011 14:05
-
-
Save matthewd/995312 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| tango:src/rbx[hydra]% rbx -Xgc.large_object=5000 reverse.rb 4900 | |
| user system total real | |
| Reversing string 4900 long 3.644228 0.004000 3.648228 ( 3.751245) | |
| tango:src/rbx[hydra]% rbx -Xgc.large_object=2700 reverse.rb 2665 | |
| user system total real | |
| Reversing string 2665 long 13.372836 0.028001 13.400837 ( 13.470050) |
This file contains hidden or 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
| require 'benchmark' | |
| def do_reverse(r) | |
| s = 'a' * r | |
| 1000000.times { s.reverse } | |
| end | |
| r = ARGV.shift.to_i | |
| Benchmark.bm do |b| | |
| b.report "Reversing string #{r} long" do | |
| do_reverse(r) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment