Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
generate uuid
Newb Newb
8/28/2008 8:43:00 AM
How Can I generate uuid ? any references or Ideas could You people
suggest.I have not even heard about it?
--
Posted via
http://www.ruby-...
.
3 Answers
Lex Williams
8/28/2008 9:58:00 AM
0
Newb Newb wrote:
> How Can I generate uuid ? any references or Ideas could You people
> suggest.I have not even heard about it?
http://en.wikipedia.org/wiki...
--
Posted via
http://www.ruby-...
.
ara.t.howard
9/2/2008 12:15:00 AM
0
On Sep 1, 2008, at 5:38 PM, Ryan Davis wrote:
>
> 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
>
>
cfp:~ > cat a.rb
require 'open-uri'
uri = '
http://s3.amazonaws.com/drawohara.com.ruby/uu...
eval open(uri).read
a = Time.now.to_f
( n = 1000 ).times{ uuid = UUID.string }
b = Time.now.to_f
elapsed = b - a
puts "uuid/min : #{ n / elapsed * 60 }"
cfp:~ > ruby a.rb
uuid/min : 113947.784509223
it's kinda a POS, but with the addition of macaddr and a few other
tidbits (state using AR for instance) it's pretty dang good : 10 times
faster and pure ruby.
a @
http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama
Ilan Berci
9/2/2008 4:06:00 PM
0
Newb Newb wrote:
> How Can I generate uuid ? any references or Ideas could You people
> suggest.I have not even heard about it?
sudo gem install guid
irb(main):001:0> require 'guid'
=> true
irb(main):002:0> Guid.new
=> b93e5a88-acf7-be64-af0b-6de00bd83fd3
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
generate uuid
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password