Skip to content

Instantly share code, notes, and snippets.

@germs12
Created September 13, 2014 17:11
Show Gist options
  • Save germs12/e3c25a857e7c504edcaf to your computer and use it in GitHub Desktop.
Save germs12/e3c25a857e7c504edcaf to your computer and use it in GitHub Desktop.
Measure String Printing
require 'benchmark'
tmp = {}
tmp['100,000,000'] = Benchmark.measure {
100000000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['10,000,000'] = Benchmark.measure {
10000000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['1,000,000'] = Benchmark.measure {
1000000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['100,000'] = Benchmark.measure {
100000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['10,000'] = Benchmark.measure {
10000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['1,000'] = Benchmark.measure {
1000.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['100'] = Benchmark.measure {
100.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['10'] = Benchmark.measure {
10.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
tmp['1'] = Benchmark.measure {
1.times do |x|
puts 'phineas and ferb! ' + x.to_s
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment