1 | # node-uuid Benchmarks
|
2 |
|
3 | ### Results
|
4 |
|
5 | To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark
|
6 |
|
7 | ### Run them yourself
|
8 |
|
9 | 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`.
|
10 |
|
11 | To prepare and run the benchmark issue;
|
12 |
|
13 | ```
|
14 | npm install uuid uuid-js
|
15 | node benchmark/benchmark.js
|
16 | ```
|
17 |
|
18 | You'll see an output like this one:
|
19 |
|
20 | ```
|
21 | # v4
|
22 | nodeuuid.v4(): 854700 uuids/second
|
23 | nodeuuid.v4('binary'): 788643 uuids/second
|
24 | nodeuuid.v4('binary', buffer): 1336898 uuids/second
|
25 | uuid(): 479386 uuids/second
|
26 | uuid('binary'): 582072 uuids/second
|
27 | uuidjs.create(4): 312304 uuids/second
|
28 |
|
29 | # v1
|
30 | nodeuuid.v1(): 938086 uuids/second
|
31 | nodeuuid.v1('binary'): 683060 uuids/second
|
32 | nodeuuid.v1('binary', buffer): 1644736 uuids/second
|
33 | uuidjs.create(1): 190621 uuids/second
|
34 | ```
|
35 |
|
36 | * The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library.
|
37 | * 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.
|
38 |
|
39 | If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file:
|
40 |
|
41 | ```
|
42 | for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done;
|
43 | ```
|
44 |
|
45 | If you're interested in how performance varies between different node versions, you can issue the above command multiple times.
|
46 |
|
47 | 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:
|
48 |
|
49 | ```
|
50 | (cd benchmark/ && ./bench.sh)
|
51 | ```
|
52 |
|
53 | 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.
|