Skip to content

Instantly share code, notes, and snippets.

@voidlock voidlock/file.rb
Created Jul 11, 2009

Embed
What would you like to do?
require 'benchmark'
require 'logger'
logger = Logger.new("/dev/null")
logger.level = Logger::INFO
puts "Simple Strings"
Benchmark.bmbm do |x|
x.report("string form") {
100_000.times do
logger.debug "a simple string message"
end
}
x.report("block form") {
100_000.times do
logger.debug { "a simple string message" }
end
}
end
puts
# Simple Strings
# Rehearsal -----------------------------------------------
# string form 0.140000 0.000000 0.140000 ( 0.146751)
# block form 0.330000 0.010000 0.340000 ( 0.336446)
# -------------------------------------- total: 0.480000sec
#
# user system total real
# string form 0.140000 0.000000 0.140000 ( 0.144761)
# block form 0.320000 0.000000 0.320000 ( 0.326912)
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.