Use SecureRandom.uuid instead of UUID4R.uuid(4)
atrzaska opened this issue · 0 comments
atrzaska commented
Problem
Currently beetle uses UUID4R gem for generating message UUID.
UUID4R gem uses OSSP-UUID native library.
OSSP-UUID library is outdated (2008). It is also not included as package in many linux distributions.
Therefore many times developers are stuck installing this library by compiling from the source.
Proposal
Replace UUID4R gem with SecureRandom.
Speed benchmark
SecureRandom seems like a 4 times faster solution than UUID4R:
[4] pry(main)> Benchmark.bmbm(100) { |b| b.report('SecureRandom.uuid') { SecureRandom.uuid }; b.report('UUID4R::uuid(4)') { UUID4R::uuid(4) } }
Rehearsal ----------------------------------------------------------------------------------------------------------------------------------------
SecureRandom.uuid 0.000037 0.000004 0.000041 ( 0.000034)
UUID4R::uuid(4) 0.000032 0.000112 0.000144 ( 0.000144)
------------------------------------------------------------------------------------------------------------------------------- total: 0.000185sec
user system total real
SecureRandom.uuid 0.000029 0.000003 0.000032 ( 0.000027)
UUID4R::uuid(4) 0.000030 0.000078 0.000108 ( 0.000103)