Created
December 28, 2013 05:59
-
-
Save ColinDKelley/8156513 to your computer and use it in GitHub Desktop.
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
Without magic comment: 3.93 seconds | |
With magic comment: 1.93 seconds | |
2X faster! |
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
# -*- 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