Skip to content

Commit fff4547

Browse files
committed
Add values benchmarks
1 parent 2c4f1f2 commit fff4547

File tree

9 files changed

+450
-0
lines changed

9 files changed

+450
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Float32Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Float32Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Float64Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Float64Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Int16Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Int16Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Int32Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Int32Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Int8Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Int8Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Uint16Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Uint16Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pkg = require( './../package.json' ).name;
25+
var Uint32Array = require( './../lib' );
26+
27+
28+
// MAIN //
29+
30+
bench( pkg+':values', function benchmark( b ) {
31+
var iter;
32+
var arr;
33+
var i;
34+
35+
arr = new Uint32Array( 2 );
36+
37+
b.tic();
38+
for ( i = 0; i < b.iterations; i++ ) {
39+
iter = arr.values();
40+
if ( typeof iter !== 'object' ) {
41+
b.fail( 'should return an object' );
42+
}
43+
}
44+
b.toc();
45+
if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) {
46+
b.fail( 'should return an iterator protocol-compliant object' );
47+
}
48+
b.pass( 'benchmark finished' );
49+
b.end();
50+
});

0 commit comments

Comments
 (0)