Skip to content

Instantly share code, notes, and snippets.

@skaes
Created February 4, 2010 18:44
Show Gist options
  • Save skaes/294965 to your computer and use it in GitHub Desktop.
Save skaes/294965 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'benchmark'
require 'uuid4r'
require 'uuidtools'
log = false
iterations = (ARGV.shift || 1_000_000).to_i
puts "# of iterations = #{iterations}"
Benchmark::bm(20) do |x|
x.report("null_time") do
for i in 0..iterations do
# do nothing
end
end
GC.enable_stats if log
GC.enable_trace if log
GC.start
GC.log_file "uuid4r.log" if log
x.report("uuid4r") do
iterations.times do
UUID4R::uuid(1)
end
end
GC.start
GC.log_file "uuidtools.log" if log
x.report("uuidtools") do
iterations.times do
UUIDTools::UUID.timestamp_create.to_s
end
end
GC.start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment