Created
June 1, 2011 04:43
-
-
Save caleywoods/1001800 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
irb(main):036:0> require 'benchmark' | |
=> true | |
irb(main):037:0> Benchmark.bmbm do |b| | |
irb(main):038:1* b.report("+=") do | |
irb(main):039:2* a = "" | |
irb(main):040:2> 100_000.times { a += "foo" } | |
irb(main):041:2> end | |
irb(main):042:1> b.report("<<") do | |
irb(main):043:2* a = "" | |
irb(main):044:2> 100_000.times { a << "foo" } | |
irb(main):045:2> end | |
irb(main):046:1> end | |
Rehearsal -------------------------------------- | |
+= 15.507000 5.413000 20.920000 ( 21.429225) | |
<< 0.031000 0.000000 0.031000 ( 0.040003) | |
---------------------------- total: 20.951000sec | |
user system total real | |
+= 15.740000 5.273000 21.013000 ( 21.897252) | |
<< 0.031000 0.000000 0.031000 ( 0.036002) | |
=> [ 15.740000 5.273000 21.013000 ( 21.897252) | |
, 0.031000 0.000000 0.031000 ( 0.036002) | |
] | |
irb(main):047:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment