Skip to content

Commit 149c31e

Browse files
committed
Fix description and add benchmarks
1 parent 24d1cc2 commit 149c31e

File tree

2 files changed

+101
-6
lines changed

2 files changed

+101
-6
lines changed

lib/node_modules/@stdlib/array/complex64/benchmark/benchmark.from.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bench( pkg+'::typed_array:from', function benchmark( b ) {
5858
b.end();
5959
});
6060

61-
bench( pkg+'::typed_array:from:len=10', function benchmark( b ) {
61+
bench( pkg+'::typed_array:from:len=5', function benchmark( b ) {
6262
var buf;
6363
var arr;
6464
var i;
@@ -80,7 +80,7 @@ bench( pkg+'::typed_array:from:len=10', function benchmark( b ) {
8080
b.end();
8181
});
8282

83-
bench( pkg+'::typed_array,clbk:from:len=10', function benchmark( b ) {
83+
bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) {
8484
var buf;
8585
var arr;
8686
var i;
@@ -128,7 +128,7 @@ bench( pkg+'::array:from', function benchmark( b ) {
128128
b.end();
129129
});
130130

131-
bench( pkg+'::array:from:len=10', function benchmark( b ) {
131+
bench( pkg+'::array:from:len=5', function benchmark( b ) {
132132
var buf;
133133
var arr;
134134
var i;
@@ -150,7 +150,7 @@ bench( pkg+'::array:from:len=10', function benchmark( b ) {
150150
b.end();
151151
});
152152

153-
bench( pkg+'::array,clbk:from:len=10', function benchmark( b ) {
153+
bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) {
154154
var buf;
155155
var arr;
156156
var i;
@@ -213,7 +213,7 @@ bench( pkg+'::iterable:from', opts, function benchmark( b ) {
213213
}
214214
});
215215

216-
bench( pkg+'::iterable:from:len=10', opts, function benchmark( b ) {
216+
bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) {
217217
var arr;
218218
var i;
219219

@@ -259,7 +259,7 @@ bench( pkg+'::iterable:from:len=10', opts, function benchmark( b ) {
259259
}
260260
});
261261

262-
bench( pkg+'::iterable,clbk:from:len=10', opts, function benchmark( b ) {
262+
bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) {
263263
var arr;
264264
var i;
265265

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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 Complex64 = require( '@stdlib/complex/float32' );
25+
var pkg = require( './../package.json' ).name;
26+
var Complex64Array = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg+':of', function benchmark( b ) {
32+
var arr;
33+
var i;
34+
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
arr = Complex64Array.of();
38+
if ( arr.length !== 0 ) {
39+
b.fail( 'should have length 0' );
40+
}
41+
}
42+
b.toc();
43+
if ( !(arr instanceof Complex64Array) ) {
44+
b.fail( 'should return an instance' );
45+
}
46+
b.pass( 'benchmark finished' );
47+
b.end();
48+
});
49+
50+
bench( pkg+'::interleaved:of:len=5', function benchmark( b ) {
51+
var buf;
52+
var arr;
53+
var i;
54+
55+
buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ];
56+
57+
b.tic();
58+
for ( i = 0; i < b.iterations; i++ ) {
59+
arr = Complex64Array.of.apply( Complex64Array, buf );
60+
if ( arr.length !== 5 ) {
61+
b.fail( 'should have length 5' );
62+
}
63+
}
64+
b.toc();
65+
if ( !(arr instanceof Complex64Array) ) {
66+
b.fail( 'should return an instance' );
67+
}
68+
b.pass( 'benchmark finished' );
69+
b.end();
70+
});
71+
72+
bench( pkg+'::complex_numbers:of:len=5', function benchmark( b ) {
73+
var buf;
74+
var arr;
75+
var i;
76+
77+
buf = [];
78+
for ( i = 0; i < 5; i++ ) {
79+
buf.push( new Complex64( 1.0, 1.0 ) );
80+
}
81+
82+
b.tic();
83+
for ( i = 0; i < b.iterations; i++ ) {
84+
arr = Complex64Array.of.apply( Complex64Array, buf );
85+
if ( arr.length !== 5 ) {
86+
b.fail( 'should have length 5' );
87+
}
88+
}
89+
b.toc();
90+
if ( !(arr instanceof Complex64Array) ) {
91+
b.fail( 'should return an instance' );
92+
}
93+
b.pass( 'benchmark finished' );
94+
b.end();
95+
});

0 commit comments

Comments
 (0)