uuid 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: node_js
2
2
  node_js:
3
- - "0.6"
4
- - "0.8"
5
- - "0.10"
3
+ - "4"
4
+ - "6"
package/AUTHORS ADDED
@@ -0,0 +1,5 @@
1
+ Robert Kieffer <robert@broofa.com>
2
+ Christoph Tavan <dev@tavan.de>
3
+ AJ ONeal <coolaj86@gmail.com>
4
+ Vincent Voyer <vincent@zeroload.net>
5
+ Roman Shtylman <shtylman@gmail.com>
package/HISTORY.md ADDED
@@ -0,0 +1,24 @@
1
+ # 3.0.0 (2016-11-17)
2
+
3
+ * remove .parse and .unparse
4
+
5
+ # 2.0.0
6
+
7
+ * Removed uuid.BufferClass
8
+
9
+ # 1.4.0
10
+
11
+ * Improved module context detection
12
+ * Removed public RNG functions
13
+
14
+ # 1.3.2
15
+
16
+ * Improve tests and handling of v1() options (Issue #24)
17
+ * Expose RNG option to allow for perf testing with different generators
18
+
19
+ # 1.3.0
20
+
21
+ * Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
22
+ * Support for node.js crypto API
23
+ * De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
24
+
package/LICENSE.md CHANGED
@@ -1,2 +1,21 @@
1
- Copyright (c) 2010-2012 Robert Kieffer
2
- MIT License - http://opensource.org/licenses/mit-license.php
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2010-2012 Robert Kieffer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,43 +1,46 @@
1
- # uuid [![Build Status](https://secure.travis-ci.org/defunctzombie/node-uuid.png?branch=master)](http://travis-ci.org/defunctzombie/node-uuid) #
2
-
3
- [![browser support](https://ci.testling.com/defunctzombie/node-uuid.png)](https://ci.testling.com/defunctzombie/node-uuid)
1
+ # uuid [![Build Status](https://secure.travis-ci.org/kelektiv/node-uuid.svg?branch=master)](http://travis-ci.org/kelektiv/node-uuid) #
4
2
 
5
3
  Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
6
4
 
7
5
  Features:
8
6
 
9
7
  * Generate RFC4122 version 1 or version 4 UUIDs
10
- * Runs in node.js and all browsers.
11
- * Cryptographically strong random # generation on supporting platforms
12
- * 1185 bytes minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )
13
- * [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)
14
-
15
- ## Getting Started
8
+ * Runs in node.js and browsers
9
+ * Cryptographically strong random number generation on supporting platforms
10
+ * Small footprint (Want something smaller? [Check this out](https://gist.github.com/982883) out!)
16
11
 
17
- Install it in your browser:
12
+ ## Quickstart - nodejs
18
13
 
19
- ```html
20
- <script src="uuid.js"></script>
21
- ```
22
-
23
- Or in node.js:
24
-
25
- ```
14
+ ```shell
26
15
  npm install uuid
27
16
  ```
28
17
 
29
18
  ```javascript
30
- var uuid = require('uuid');
19
+ const uuid = require('uuid');
20
+
21
+ // Generate a v4 (random) id
22
+ uuid() // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
31
23
 
32
24
  // Generate a v1 (time-based) id
33
25
  uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
26
+ ```
34
27
 
35
- // Generate a v4 (random) id
36
- uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
28
+ ## Quickstart - browser
29
+
30
+ ** Not recommende for production or even semi-production use. Use a bundling tool instead (i.e. webpack, browserify, rollup, etc)**
31
+
32
+ [wzrd.in](https://github.com/jfhbrook/wzrd.in) will serve up any npm module after performing basic bundling and minification.
33
+
34
+ ```html
35
+ <script src="https://wzrd.in/standalone/uuid@latest"></script>
37
36
  ```
38
37
 
39
38
  ## API
40
39
 
40
+ ### uuid(...)
41
+
42
+ Generate a V4 uuid. See uuid.v4 documentation below.
43
+
41
44
  ### uuid.v1([`options` [, `buffer` [, `offset`]]])
42
45
 
43
46
  Generate and return a RFC4122 v1 (timestamp-based) UUID.
@@ -73,7 +76,7 @@ Example: In-place generation of two binary IDs
73
76
 
74
77
  ```javascript
75
78
  // Generate two ids in an array
76
- var arr = new Array(32); // -> []
79
+ const arr = new Array(32); // -> []
77
80
  uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
78
81
  uuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
79
82
 
@@ -111,95 +114,17 @@ uuid.v4({
111
114
  Example: Generate two IDs in a single buffer
112
115
 
113
116
  ```javascript
114
- var buffer = new Array(32); // (or 'new Buffer' in node.js)
117
+ const buffer = new Array(32); // (or 'new Buffer' in node.js)
115
118
  uuid.v4(null, buffer, 0);
116
119
  uuid.v4(null, buffer, 16);
117
120
  ```
118
121
 
119
- ### uuid.parse(id[, buffer[, offset]])
120
- ### uuid.unparse(buffer[, offset])
121
-
122
- Parse and unparse UUIDs
123
-
124
- * `id` - (String) UUID(-like) string
125
- * `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used
126
- * `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0
127
-
128
- Example parsing and unparsing a UUID string
129
-
130
- ```javascript
131
- var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>
132
- var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'
133
- ```
134
-
135
- ### uuid.noConflict()
136
-
137
- (Browsers only) Set `uuid` property back to it's previous value.
138
-
139
- Returns the uuid object.
140
-
141
- Example:
142
-
143
- ```javascript
144
- var myUuid = uuid.noConflict();
145
- myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
146
- ```
147
-
148
- ## Deprecated APIs
149
-
150
- Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.
151
-
152
- ### uuid([format [, buffer [, offset]]])
153
-
154
- uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).
155
-
156
- ### uuid.BufferClass
157
-
158
- The class of container created when generating binary uuid data if no buffer argument is specified. This is expected to go away, with no replacement API.
159
-
160
122
  ## Testing
161
123
 
162
- In node.js
163
-
164
124
  ```
165
- > cd test
166
- > node test.js
167
- ```
168
-
169
- In Browser
170
-
125
+ npm test
171
126
  ```
172
- open test/test.html
173
- ```
174
-
175
- ### Benchmarking
176
-
177
- Requires node.js
178
-
179
- ```
180
- cd benchmark/
181
- npm install
182
- node benchmark.js
183
- ```
184
-
185
- For a more complete discussion of uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/uuid/wiki/Benchmark)
186
-
187
- For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).
188
-
189
- ## Release notes
190
-
191
- ### 1.4.0
192
-
193
- * Improved module context detection
194
- * Removed public RNG functions
195
-
196
- ### 1.3.2
197
-
198
- * Improve tests and handling of v1() options (Issue #24)
199
- * Expose RNG option to allow for perf testing with different generators
200
127
 
201
- ### 1.3.0
128
+ ## Legacy node-uuid package
202
129
 
203
- * Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
204
- * Support for node.js crypto API
205
- * De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code
130
+ The code for the legacy node-uuid package is available in the `node-uuid` branch.
package/bin/uuid ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ var path = require('path');
4
+ var uuid = require(path.join(__dirname, '..'));
5
+
6
+ var arg = process.argv[2];
7
+
8
+ if ('--help' === arg) {
9
+ console.log('\n USAGE: uuid [version] [options]\n\n');
10
+ console.log(' options:\n');
11
+ console.log(' --help Display this message and exit\n');
12
+ process.exit(0);
13
+ }
14
+
15
+ if (null == arg) {
16
+ console.log(uuid());
17
+ process.exit(0);
18
+ }
19
+
20
+ if ('v1' !== arg && 'v4' !== arg) {
21
+ console.error('Version must be RFC4122 version 1 or version 4, denoted as "v1" or "v4"');
22
+ process.exit(1);
23
+ }
24
+
25
+ console.log(uuid[arg]());
26
+ process.exit(0);
@@ -1,7 +1,8 @@
1
1
 
2
2
  var rng;
3
3
 
4
- if (global.crypto && crypto.getRandomValues) {
4
+ var crypto = global.crypto || global.msCrypto; // for IE 11
5
+ if (crypto && crypto.getRandomValues) {
5
6
  // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
6
7
  // Moderately fast, high quality
7
8
  var _rnds8 = new Uint8Array(16);
File without changes
package/package.json CHANGED
@@ -1,45 +1,28 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "2.0.0",
4
- "description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
3
+ "version": "3.0.0",
4
+ "description": "RFC4122 (v1 and v4) generator",
5
5
  "keywords": [
6
6
  "uuid",
7
7
  "guid",
8
8
  "rfc4122"
9
9
  ],
10
- "author": "Robert Kieffer <robert@broofa.com>",
11
- "contributors": [
12
- {
13
- "name": "Christoph Tavan <dev@tavan.de>",
14
- "github": "https://github.com/ctavan"
15
- },
16
- {
17
- "name": "Vincent Voyer <vincent@zeroload.net>",
18
- "github": "https://github.com/vvo"
19
- }
20
- ],
10
+ "license": "MIT",
21
11
  "main": "./uuid.js",
12
+ "bin": {
13
+ "uuid": "./bin/uuid"
14
+ },
22
15
  "devDependencies": {
23
- "mocha": "1.8.0"
16
+ "mocha": "3.1.2"
24
17
  },
25
18
  "scripts": {
26
19
  "test": "mocha test/test.js"
27
20
  },
28
21
  "browser": {
29
- "./rng.js": "./rng-browser.js"
22
+ "./lib/rng.js": "./lib/rng-browser.js"
30
23
  },
31
24
  "repository": {
32
25
  "type": "git",
33
- "url": "https://github.com/shtylman/node-uuid.git"
34
- },
35
- "testling": {
36
- "browsers": [
37
- "ie6..latest",
38
- "firefox/3.6..latest",
39
- "chrome/22..latest",
40
- "safari/5.1..latest"
41
- ],
42
- "harness": "mocha-tdd",
43
- "files": "test/*.js"
26
+ "url": "https://github.com/kelektiv/node-uuid.git"
44
27
  }
45
- }
28
+ }
package/test/mocha.opts CHANGED
@@ -1 +1,3 @@
1
1
  --ui qunit
2
+ --reporter spec
3
+ --check-leaks
package/test/test.js CHANGED
@@ -94,12 +94,3 @@ test('ids spanning 1ms boundary are 100ns apart', function() {
94
94
  var dt = parseInt(after, 16) - parseInt(before, 16);
95
95
  assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart');
96
96
  });
97
-
98
- test('parse/unparse', function() {
99
- var id = '00112233445566778899aabbccddeeff';
100
- assert(uuid.unparse(uuid.parse(id.substr(0,10))) ==
101
- '00112233-4400-0000-0000-000000000000', 'Short parse');
102
- assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) ==
103
- '00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse');
104
- });
105
-
package/uuid.js CHANGED
@@ -1,43 +1,19 @@
1
- // uuid.js
2
- //
3
- // Copyright (c) 2010-2012 Robert Kieffer
4
- // MIT License - http://opensource.org/licenses/mit-license.php
5
-
6
1
  // Unique ID creation requires a high quality random # generator. We feature
7
2
  // detect to determine the best RNG source, normalizing to a function that
8
3
  // returns 128-bits of randomness, since that's what's usually required
9
- var _rng = require('./rng');
4
+ var _rng = require('./lib/rng');
10
5
 
11
6
  // Maps for number <-> hex string conversion
12
7
  var _byteToHex = [];
13
8
  var _hexToByte = {};
14
- for (var i = 0; i < 256; i++) {
9
+ for (var i = 0; i < 256; ++i) {
15
10
  _byteToHex[i] = (i + 0x100).toString(16).substr(1);
16
11
  _hexToByte[_byteToHex[i]] = i;
17
12
  }
18
13
 
19
- // **`parse()` - Parse a UUID into it's component bytes**
20
- function parse(s, buf, offset) {
21
- var i = (buf && offset) || 0, ii = 0;
22
-
23
- buf = buf || [];
24
- s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
25
- if (ii < 16) { // Don't overflow!
26
- buf[i + ii++] = _hexToByte[oct];
27
- }
28
- });
29
-
30
- // Zero out remaining bytes if string was short
31
- while (ii < 16) {
32
- buf[i + ii++] = 0;
33
- }
34
-
35
- return buf;
36
- }
37
-
38
- // **`unparse()` - Convert UUID byte array (ala parse()) into a string**
39
- function unparse(buf, offset) {
40
- var i = offset || 0, bth = _byteToHex;
14
+ function buff_to_string(buf, offset) {
15
+ var i = offset || 0;
16
+ var bth = _byteToHex;
41
17
  return bth[buf[i++]] + bth[buf[i++]] +
42
18
  bth[buf[i++]] + bth[buf[i++]] + '-' +
43
19
  bth[buf[i++]] + bth[buf[i++]] + '-' +
@@ -137,11 +113,11 @@ function v1(options, buf, offset) {
137
113
 
138
114
  // `node`
139
115
  var node = options.node || _nodeId;
140
- for (var n = 0; n < 6; n++) {
116
+ for (var n = 0; n < 6; ++n) {
141
117
  b[i + n] = node[n];
142
118
  }
143
119
 
144
- return buf ? buf : unparse(b);
120
+ return buf ? buf : buff_to_string(b);
145
121
  }
146
122
 
147
123
  // **`v4()` - Generate random UUID**
@@ -165,19 +141,17 @@ function v4(options, buf, offset) {
165
141
 
166
142
  // Copy bytes to buffer, if provided
167
143
  if (buf) {
168
- for (var ii = 0; ii < 16; ii++) {
144
+ for (var ii = 0; ii < 16; ++ii) {
169
145
  buf[i + ii] = rnds[ii];
170
146
  }
171
147
  }
172
148
 
173
- return buf || unparse(rnds);
149
+ return buf || buff_to_string(rnds);
174
150
  }
175
151
 
176
152
  // Export public API
177
153
  var uuid = v4;
178
154
  uuid.v1 = v1;
179
155
  uuid.v4 = v4;
180
- uuid.parse = parse;
181
- uuid.unparse = unparse;
182
156
 
183
157
  module.exports = uuid;
@@ -1,53 +0,0 @@
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.
@@ -1,174 +0,0 @@
1
- #!/opt/local/bin/gnuplot -persist
2
- #
3
- #
4
- # G N U P L O T
5
- # Version 4.4 patchlevel 3
6
- # last modified March 2011
7
- # System: Darwin 10.8.0
8
- #
9
- # Copyright (C) 1986-1993, 1998, 2004, 2007-2010
10
- # Thomas Williams, Colin Kelley and many others
11
- #
12
- # gnuplot home: http://www.gnuplot.info
13
- # faq, bugs, etc: type "help seeking-assistance"
14
- # immediate help: type "help"
15
- # plot window: hit 'h'
16
- set terminal postscript eps noenhanced defaultplex \
17
- leveldefault color colortext \
18
- solid linewidth 1.2 butt noclip \
19
- palfuncparam 2000,0.003 \
20
- "Helvetica" 14
21
- set output 'bench.eps'
22
- unset clip points
23
- set clip one
24
- unset clip two
25
- set bar 1.000000 front
26
- set border 31 front linetype -1 linewidth 1.000
27
- set xdata
28
- set ydata
29
- set zdata
30
- set x2data
31
- set y2data
32
- set timefmt x "%d/%m/%y,%H:%M"
33
- set timefmt y "%d/%m/%y,%H:%M"
34
- set timefmt z "%d/%m/%y,%H:%M"
35
- set timefmt x2 "%d/%m/%y,%H:%M"
36
- set timefmt y2 "%d/%m/%y,%H:%M"
37
- set timefmt cb "%d/%m/%y,%H:%M"
38
- set boxwidth
39
- set style fill empty border
40
- set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1
41
- set style circle radius graph 0.02, first 0, 0
42
- set dummy x,y
43
- set format x "% g"
44
- set format y "% g"
45
- set format x2 "% g"
46
- set format y2 "% g"
47
- set format z "% g"
48
- set format cb "% g"
49
- set angles radians
50
- unset grid
51
- set key title ""
52
- set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox
53
- set key noinvert samplen 4 spacing 1 width 0 height 0
54
- set key maxcolumns 2 maxrows 0
55
- unset label
56
- unset arrow
57
- set style increment default
58
- unset style line
59
- set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0
60
- unset style arrow
61
- set style histogram clustered gap 2 title offset character 0, 0, 0
62
- unset logscale
63
- set offsets graph 0.05, 0.15, 0, 0
64
- set pointsize 1.5
65
- set pointintervalbox 1
66
- set encoding default
67
- unset polar
68
- unset parametric
69
- unset decimalsign
70
- set view 60, 30, 1, 1
71
- set samples 100, 100
72
- set isosamples 10, 10
73
- set surface
74
- unset contour
75
- set clabel '%8.3g'
76
- set mapping cartesian
77
- set datafile separator whitespace
78
- unset hidden3d
79
- set cntrparam order 4
80
- set cntrparam linear
81
- set cntrparam levels auto 5
82
- set cntrparam points 5
83
- set size ratio 0 1,1
84
- set origin 0,0
85
- set style data points
86
- set style function lines
87
- set xzeroaxis linetype -2 linewidth 1.000
88
- set yzeroaxis linetype -2 linewidth 1.000
89
- set zzeroaxis linetype -2 linewidth 1.000
90
- set x2zeroaxis linetype -2 linewidth 1.000
91
- set y2zeroaxis linetype -2 linewidth 1.000
92
- set ticslevel 0.5
93
- set mxtics default
94
- set mytics default
95
- set mztics default
96
- set mx2tics default
97
- set my2tics default
98
- set mcbtics default
99
- set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
100
- set xtics norangelimit
101
- set xtics ()
102
- set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
103
- set ytics autofreq norangelimit
104
- set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0
105
- set ztics autofreq norangelimit
106
- set nox2tics
107
- set noy2tics
108
- set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
109
- set cbtics autofreq norangelimit
110
- set title ""
111
- set title offset character 0, 0, 0 font "" norotate
112
- set timestamp bottom
113
- set timestamp ""
114
- set timestamp offset character 0, 0, 0 font "" norotate
115
- set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
116
- set autoscale rfixmin
117
- set autoscale rfixmax
118
- set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
119
- set autoscale tfixmin
120
- set autoscale tfixmax
121
- set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
122
- set autoscale ufixmin
123
- set autoscale ufixmax
124
- set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
125
- set autoscale vfixmin
126
- set autoscale vfixmax
127
- set xlabel ""
128
- set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
129
- set x2label ""
130
- set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate
131
- set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] )
132
- set autoscale xfixmin
133
- set autoscale xfixmax
134
- set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] )
135
- set autoscale x2fixmin
136
- set autoscale x2fixmax
137
- set ylabel ""
138
- set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
139
- set y2label ""
140
- set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
141
- set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] )
142
- set autoscale yfixmin
143
- set autoscale yfixmax
144
- set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] )
145
- set autoscale y2fixmin
146
- set autoscale y2fixmax
147
- set zlabel ""
148
- set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
149
- set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
150
- set autoscale zfixmin
151
- set autoscale zfixmax
152
- set cblabel ""
153
- set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
154
- set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
155
- set autoscale cbfixmin
156
- set autoscale cbfixmax
157
- set zero 1e-08
158
- set lmargin -1
159
- set bmargin -1
160
- set rmargin -1
161
- set tmargin -1
162
- set pm3d explicit at s
163
- set pm3d scansautomatic
164
- set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean
165
- set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
166
- set palette rgbformulae 7, 5, 15
167
- set colorbox default
168
- set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault
169
- set loadpath
170
- set fontpath
171
- set fit noerrorvariables
172
- GNUTERM = "aqua"
173
- plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2
174
- # EOF
@@ -1,34 +0,0 @@
1
- #!/bin/bash
2
-
3
- # for a given node version run:
4
- # for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done;
5
-
6
- PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte')
7
- FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es)
8
- INDICES=(2 3 2 3 2 2 2 2 2)
9
- VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " )
10
- TMPJOIN="tmp_join"
11
- OUTPUT="bench_results.txt"
12
-
13
- for I in ${!FILES[*]}; do
14
- F=${FILES[$I]}
15
- P=${PATTERNS[$I]}
16
- INDEX=${INDICES[$I]}
17
- echo "version $F" > $F
18
- for V in $VERSIONS; do
19
- (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F
20
- done
21
- if [ $I == 0 ]; then
22
- cat $F > $TMPJOIN
23
- else
24
- join $TMPJOIN $F > $OUTPUT
25
- cp $OUTPUT $TMPJOIN
26
- fi
27
- rm $F
28
- done
29
-
30
- rm $TMPJOIN
31
-
32
- gnuplot bench.gnu
33
- convert -density 200 -resize 800x560 -flatten bench.eps bench.png
34
- rm bench.eps
@@ -1,34 +0,0 @@
1
- /*
2
- Test performance of native C UUID generation
3
-
4
- To Compile: cc -luuid benchmark-native.c -o benchmark-native
5
- */
6
-
7
- #include <stdio.h>
8
- #include <unistd.h>
9
- #include <sys/time.h>
10
- #include <uuid/uuid.h>
11
-
12
- int main() {
13
- uuid_t myid;
14
- char buf[36+1];
15
- int i;
16
- struct timeval t;
17
- double start, finish;
18
-
19
- gettimeofday(&t, NULL);
20
- start = t.tv_sec + t.tv_usec/1e6;
21
-
22
- int n = 2e5;
23
- for (i = 0; i < n; i++) {
24
- uuid_generate(myid);
25
- uuid_unparse(myid, buf);
26
- }
27
-
28
- gettimeofday(&t, NULL);
29
- finish = t.tv_sec + t.tv_usec/1e6;
30
- double dur = finish - start;
31
-
32
- printf("%d uuids/sec", (int)(n/dur));
33
- return 0;
34
- }
@@ -1,84 +0,0 @@
1
- try {
2
- var nodeuuid = require('../uuid');
3
- } catch (e) {
4
- console.error('node-uuid require failed - skipping tests');
5
- }
6
-
7
- try {
8
- var uuid = require('uuid');
9
- } catch (e) {
10
- console.error('uuid require failed - skipping tests');
11
- }
12
-
13
- try {
14
- var uuidjs = require('uuid-js');
15
- } catch (e) {
16
- console.error('uuid-js require failed - skipping tests');
17
- }
18
-
19
- var N = 5e5;
20
-
21
- function rate(msg, t) {
22
- console.log(msg + ': ' +
23
- (N / (Date.now() - t) * 1e3 | 0) +
24
- ' uuids/second');
25
- }
26
-
27
- console.log('# v4');
28
-
29
- // node-uuid - string form
30
- if (nodeuuid) {
31
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4();
32
- rate('nodeuuid.v4() - using node.js crypto RNG', t);
33
-
34
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG});
35
- rate('nodeuuid.v4() - using Math.random() RNG', t);
36
-
37
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary');
38
- rate('nodeuuid.v4(\'binary\')', t);
39
-
40
- var buffer = new nodeuuid.BufferClass(16);
41
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer);
42
- rate('nodeuuid.v4(\'binary\', buffer)', t);
43
- }
44
-
45
- // libuuid - string form
46
- if (uuid) {
47
- for (var i = 0, t = Date.now(); i < N; i++) uuid();
48
- rate('uuid()', t);
49
-
50
- for (var i = 0, t = Date.now(); i < N; i++) uuid('binary');
51
- rate('uuid(\'binary\')', t);
52
- }
53
-
54
- // uuid-js - string form
55
- if (uuidjs) {
56
- for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4);
57
- rate('uuidjs.create(4)', t);
58
- }
59
-
60
- // 140byte.es
61
- for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)});
62
- rate('140byte.es_v4', t);
63
-
64
- console.log('');
65
- console.log('# v1');
66
-
67
- // node-uuid - v1 string form
68
- if (nodeuuid) {
69
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1();
70
- rate('nodeuuid.v1()', t);
71
-
72
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary');
73
- rate('nodeuuid.v1(\'binary\')', t);
74
-
75
- var buffer = new nodeuuid.BufferClass(16);
76
- for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer);
77
- rate('nodeuuid.v1(\'binary\', buffer)', t);
78
- }
79
-
80
- // uuid-js - v1 string form
81
- if (uuidjs) {
82
- for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1);
83
- rate('uuidjs.create(1)', t);
84
- }
@@ -1,9 +0,0 @@
1
- {
2
- "name": "benchmark-uuid",
3
- "private": true,
4
- "description": "Benchmarks for node-uuid",
5
- "dependencies": {
6
- "uuid": "1.4.1",
7
- "uuid-js": "0.7.4"
8
- }
9
- }
package/misc/compare.js DELETED
@@ -1,62 +0,0 @@
1
- var assert = require('assert'),
2
- nodeuuid = require('../'),
3
- uuidjs = require('uuid-js'),
4
- util = require('util'),
5
- exec = require('child_process').exec,
6
- os = require('os');
7
-
8
- // On Mac Os X / macports there's only the ossp-uuid package that provides uuid
9
- // On Linux there's uuid-runtime which provides uuidgen
10
- var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t';
11
-
12
- function compare(ids) {
13
- console.log(ids);
14
- for (var i = 0; i < ids.length; i++) {
15
- var id = ids[i].split('-');
16
- id = [id[2], id[1], id[0]].join('');
17
- ids[i] = id;
18
- }
19
- var sorted = ([].concat(ids)).sort();
20
-
21
- if (sorted.toString() !== ids.toString()) {
22
- console.log('Warning: sorted !== ids');
23
- } else {
24
- console.log('everything in order!');
25
- }
26
- }
27
-
28
- // Test time order of v1 uuids
29
- var ids = [];
30
- while (ids.length < 10e3) ids.push(nodeuuid.v1());
31
-
32
- var max = 10;
33
- console.log('node-uuid:');
34
- ids = [];
35
- for (var i = 0; i < max; i++) ids.push(nodeuuid.v1());
36
- compare(ids);
37
-
38
- console.log('');
39
- console.log('uuidjs:');
40
- ids = [];
41
- for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString());
42
- compare(ids);
43
-
44
- console.log('');
45
- console.log('libuuid:');
46
- ids = [];
47
- var count = 0;
48
- var last = function() {
49
- compare(ids);
50
- }
51
- var cb = function(err, stdout, stderr) {
52
- ids.push(stdout.substring(0, stdout.length-1));
53
- count++;
54
- if (count < max) {
55
- return next();
56
- }
57
- last();
58
- };
59
- var next = function() {
60
- exec(uuidCmd, cb);
61
- };
62
- next();
package/misc/perf.js DELETED
@@ -1,102 +0,0 @@
1
- var assert = require('assert');
2
-
3
- var uuid = require('../');
4
-
5
- var log = console.log;
6
-
7
- var generators = {
8
- v1: uuid.v1,
9
- v4: uuid.v4
10
- };
11
-
12
- var UUID_FORMAT = {
13
- v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
14
- v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i
15
- };
16
-
17
- var N = 1e4;
18
-
19
- // Get %'age an actual value differs from the ideal value
20
- function divergence(actual, ideal) {
21
- return Math.round(100*100*(actual - ideal)/ideal)/100;
22
- }
23
-
24
- function rate(msg, t) {
25
- log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second');
26
- }
27
-
28
- for (var version in generators) {
29
- var counts = {}, max = 0;
30
- var generator = generators[version];
31
- var format = UUID_FORMAT[version];
32
-
33
- log('\nSanity check ' + N + ' ' + version + ' uuids');
34
- for (var i = 0, ok = 0; i < N; i++) {
35
- id = generator();
36
- if (!format.test(id)) {
37
- throw Error(id + ' is not a valid UUID string');
38
- }
39
-
40
- if (id != uuid.unparse(uuid.parse(id))) {
41
- assert(fail, id + ' is not a valid id');
42
- }
43
-
44
- // Count digits for our randomness check
45
- if (version == 'v4') {
46
- var digits = id.replace(/-/g, '').split('');
47
- for (var j = digits.length-1; j >= 0; j--) {
48
- var c = digits[j];
49
- max = Math.max(max, counts[c] = (counts[c] || 0) + 1);
50
- }
51
- }
52
- }
53
-
54
- // Check randomness for v4 UUIDs
55
- if (version == 'v4') {
56
- // Limit that we get worried about randomness. (Purely empirical choice, this!)
57
- var limit = 2*100*Math.sqrt(1/N);
58
-
59
- log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)');
60
-
61
- for (var i = 0; i < 16; i++) {
62
- var c = i.toString(16);
63
- var bar = '', n = counts[c], p = Math.round(n/max*100|0);
64
-
65
- // 1-3,5-8, and D-F: 1:16 odds over 30 digits
66
- var ideal = N*30/16;
67
- if (i == 4) {
68
- // 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits
69
- ideal = N*(1 + 30/16);
70
- } else if (i >= 8 && i <= 11) {
71
- // 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits
72
- ideal = N*(1/4 + 30/16);
73
- } else {
74
- // Otherwise: 1:16 odds on 30 digits
75
- ideal = N*30/16;
76
- }
77
- var d = divergence(n, ideal);
78
-
79
- // Draw bar using UTF squares (just for grins)
80
- var s = n/max*50 | 0;
81
- while (s--) bar += '=';
82
-
83
- assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)');
84
- }
85
- }
86
- }
87
-
88
- // Perf tests
89
- for (var version in generators) {
90
- log('\nPerformance testing ' + version + ' UUIDs');
91
- var generator = generators[version];
92
- var buf = new uuid.BufferClass(16);
93
-
94
- for (var i = 0, t = Date.now(); i < N; i++) generator();
95
- rate('uuid.' + version + '()', t);
96
-
97
- for (var i = 0, t = Date.now(); i < N; i++) generator('binary');
98
- rate('uuid.' + version + '(\'binary\')', t);
99
-
100
- for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf);
101
- rate('uuid.' + version + '(\'binary\', buffer)', t);
102
- }