Skip to content

Instantly share code, notes, and snippets.

@rahul100885
Created December 22, 2011 09:45
Show Gist options
  • Save rahul100885/1509722 to your computer and use it in GitHub Desktop.
Save rahul100885/1509722 to your computer and use it in GitHub Desktop.
Benchmarking for uuid and hex(16)
require 'benchmark'
require 'securerandom'
Benchmark.bm(7) do |x|
x.report("UUID") { SecureRandom.uuid }
x.report("hex(16)") { SecureRandom.hex(16) }
end
#Output
# user system total real
#UUID 0.000000 0.000000 0.000000 ( 0.000182)
#hex(16) 0.000000 0.000000 0.000000 ( 0.000010)
# user system total real
#UUID 0.000000 0.000000 0.000000 ( 0.000152)
#hex(16) 0.000000 0.000000 0.000000 ( 0.000010)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment