Skip to content

Instantly share code, notes, and snippets.

@rhysd rhysd/bench.rb

Created Jun 18, 2017
Embed
What would you like to do?
#!/usr/bin/env ruby
require 'benchmark'
puts Benchmark.measure {
s = ""
5000000.times do
s << "hey, hey, "
end
}
puts Benchmark.measure {
s = StringIO.new
5000000.times do
s << "hey, hey, "
end
s.string
}
0.510000 0.020000 0.530000 ( 0.532377)
0.820000 0.030000 0.850000 ( 0.848875)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.