UNPKG

2.03 kBMarkdownView Raw
1# node-uuid Benchmarks
2
3### Results
4
5To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark
6
7### Run them yourself
8
9node-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
11To prepare and run the benchmark issue;
12
13```
14npm install uuid uuid-js
15node benchmark/benchmark.js
16```
17
18You'll see an output like this one:
19
20```
21# v4
22nodeuuid.v4(): 854700 uuids/second
23nodeuuid.v4('binary'): 788643 uuids/second
24nodeuuid.v4('binary', buffer): 1336898 uuids/second
25uuid(): 479386 uuids/second
26uuid('binary'): 582072 uuids/second
27uuidjs.create(4): 312304 uuids/second
28
29# v1
30nodeuuid.v1(): 938086 uuids/second
31nodeuuid.v1('binary'): 683060 uuids/second
32nodeuuid.v1('binary', buffer): 1644736 uuids/second
33uuidjs.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
39If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file:
40
41```
42for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done;
43```
44
45If you're interested in how performance varies between different node versions, you can issue the above command multiple times.
46
47You 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
53This 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.