From: Ryan Davis Date: 2008-09-02T08:38:03+09:00 Subject: Re: generate uuid On Sep 1, 2008, at 14:48 , James Gray wrote: > My favorite trick is: > > uuid = `uuidgen`.strip > > It has always been fast enough for my needs. that's nice. 10k real uuids in 1 minute is perfectly acceptable for almost all cases. thanks. % ./blah.rb 10000 # of iterations = 10000 user system total real null_time 0.000000 0.000000 0.000000 ( 0.001486) ezra 0.200000 0.000000 0.200000 ( 0.201678) uuidgen 1.160000 12.630000 58.190000 ( 56.684045) ---- puts "# of iterations = #{max}" Benchmark::bm(20) do |x| x.report("null_time") do for i in 0..max do # do nothing end end x.report("ezra") do for i in 0..max do fast_token end end x.report("uuidgen") do for i in 0..max do `uuidgen`.strip end end end