Created
January 2, 2013 20:45
-
-
Save whoisstan/4437834 to your computer and use it in GitHub Desktop.
Very Basic benchmark use example to clarify results
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
require 'benchmark' | |
require 'benchmark/ips' | |
Benchmark.ips do |r| | |
N = 100000 | |
r.report("<< ") do | |
s = "" | |
N.times { s << "." } | |
end | |
r.report("<< many") do | |
s = "" | |
N.times { s << "." << "." << "." << "." << "." << "." << "." } | |
end | |
end | |
Calculating ------------------------------------- | |
<< 4 i/100ms | |
<< many 1 i/100ms | |
------------------------------------------------- | |
<< 41.7 (±2.4%) i/s - 212 in 5.090942s | |
<< many 8.2 (±0.0%) i/s - 41 in 5.032027s | |
=> [ << 41.7 (±2.4%) i/s - 212 in 5.090942s, << many 8.2 (±0.0%) i/s - 41 in 5.032027s] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment