d9ca1965131026cee50bcb048adf4cdb172261f6a1182bc55de14639a5510e161a5988d0942424683a35bb2accf4dce375e678ff6195c04af25ba5411e588c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # node-uuid Benchmarks
  2. ### Results
  3. To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark
  4. ### Run them yourself
  5. node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`.
  6. To prepare and run the benchmark issue;
  7. ```
  8. npm install uuid uuid-js
  9. node benchmark/benchmark.js
  10. ```
  11. You'll see an output like this one:
  12. ```
  13. # v4
  14. nodeuuid.v4(): 854700 uuids/second
  15. nodeuuid.v4('binary'): 788643 uuids/second
  16. nodeuuid.v4('binary', buffer): 1336898 uuids/second
  17. uuid(): 479386 uuids/second
  18. uuid('binary'): 582072 uuids/second
  19. uuidjs.create(4): 312304 uuids/second
  20. # v1
  21. nodeuuid.v1(): 938086 uuids/second
  22. nodeuuid.v1('binary'): 683060 uuids/second
  23. nodeuuid.v1('binary', buffer): 1644736 uuids/second
  24. uuidjs.create(1): 190621 uuids/second
  25. ```
  26. * The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library.
  27. * The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK.
  28. If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file:
  29. ```
  30. for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done;
  31. ```
  32. If you're interested in how performance varies between different node versions, you can issue the above command multiple times.
  33. You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot:
  34. ```
  35. (cd benchmark/ && ./bench.sh)
  36. ```
  37. This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then.