Skip to content

Commit 04ebd58

Browse files
committed
Add browser benchmark
1 parent 48ef1fc commit 04ebd58

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
// MODULES //
4+
5+
var bench = require( '@stdlib/bench' );
6+
var isNull = require( '@stdlib/assert/is-null' );
7+
var pkg = require( './../package.json' ).name;
8+
var getuid = require( './../lib/browser.js' );
9+
10+
11+
// MAIN //
12+
13+
bench( pkg+'::browser', function benchmark( b ) {
14+
var uid;
15+
var i;
16+
17+
b.tic();
18+
for ( i = 0; i < b.iterations; i++ ) {
19+
// Note: the following *could* be optimized away via loop-invariant code motion. If so, the entire loop will disappear.
20+
uid = getuid();
21+
if ( !isNull( uid ) ) {
22+
b.fail( 'should return null' );
23+
}
24+
}
25+
b.toc();
26+
if ( !isNull( uid ) ) {
27+
b.fail( 'should return null' );
28+
}
29+
b.pass( 'benchmark finished' );
30+
b.end();
31+
});

0 commit comments

Comments
 (0)