Last active
December 10, 2015 12:59
-
-
Save bradland/4438185 to your computer and use it in GitHub Desktop.
Benchmark two types of log tags
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
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'date' | |
require 'securerandom' | |
Benchmark.bm(15) do|b| | |
ITERATE = 100_000 | |
timestamp = Proc.new {Time.now.strftime('%Y-%m-%d %H:%M:%S.%L')} | |
b.report("proc time call") do | |
ITERATE.times { log_tags = [timestamp.call, SecureRandom.hex(16)] } | |
end | |
emptyproc = Proc.new {nil} | |
b.report("proc empty call") do | |
ITERATE.times { log_tags = [emptyproc.call, SecureRandom.hex(16)] } | |
end | |
b.report("uuid only") do | |
ITERATE.times { log_tags = [SecureRandom.hex(16)] } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results: