dwyl/aguid

Investigate how node-uuid is so fast

nelsonic opened this issue · 2 comments

See: https://github.com/broofa/node-uuid/blob/master/benchmark/benchmark.js

Try it:

$ git clone https://github.com/broofa/node-uuid.git && cd node-uuid
$ npm install uuid uuid-js
$ node benchmark/benchmark.js

#### v4
nodeuuid.v4() - using node.js crypto RNG: 2840909 uuids/second
nodeuuid.v4() - using Math.random() RNG: 2747252 uuids/second
nodeuuid.v4('binary'): 2293577 uuids/second
nodeuuid.v4('binary', buffer): 2369668 uuids/second
uuid(): 171585 uuids/second
uuid('binary'): 162022 uuids/second
uuidjs.create(4): 433651 uuids/second
140byte.es_v4: 266951 uuids/second

#### v1
nodeuuid.v1(): 988142 uuids/second
nodeuuid.v1('binary'): 563063 uuids/second
nodeuuid.v1('binary', buffer): 851788 uuids/second
uuidjs.create(1): 320718 uuids/second

Reading the history of the module is a good lesson in improving performance over time.
https://github.com/broofa/node-uuid/commits/master/uuid.js
I highly recommend it to anyone curious about high performance (but terse) JS.