Skip to content

Instantly share code, notes, and snippets.

@ColinDKelley
Created December 28, 2013 05:59
Show Gist options
  • Save ColinDKelley/8156513 to your computer and use it in GitHub Desktop.
Save ColinDKelley/8156513 to your computer and use it in GitHub Desktop.
Without magic comment: 3.93 seconds
With magic comment: 1.93 seconds
2X faster!
# -*- immutable: string -*-
require 'benchmark.rb'
class NullLogger
def info(message)
end
end
LOGGER = NullLogger.new
def log(message)
unless message == "none"
LOGGER.info("prefix")
LOGGER.info(message)
end
end
res = Benchmark.measure do
10_000_000.times do
log("abcd")
end
end
puts res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment