From: Gary Wright Date: 2007-03-12T09:16:43+09:00 Subject: Re: generate UUID On Mar 11, 2007, at 6:00 PM, Ryan Davis wrote: > On Mar 8, 2007, at 5:38 PM, Aaron Smith wrote: > > We're using uuidtools at work and it is quite possibly the worst > code I've ever come across. Convoluted, obfuscated for the sake of > "security" and slow as hell. > > % ./blah.rb 100 > ... > uuidtools-original 0.130000 4.650000 4.780000 ( 4.782855) > > Yes, 21 uuids per second! > > I got a 400x improvement out of it by dropping this into our config/ > environment.rb: > > def UUID.true_random > (1..8).to_a.map { rand(0x10000) }.pack("n8") > end I couldn't tell from the message if Ryan or Aaron wrote the parts I quoted above... I'm not an expert on UUIDs but I think there is a real semantic difference between a UUID and a random number of the same (binary) length. RFC 4122 has lots of good information on UUIDs: http://www.ietf.org/rfc/rfc4122.txt Gary Wright