Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 10 additions & 98 deletions lib/node_modules/@stdlib/assert/is-cube-number/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

/* eslint-disable no-new-wrappers, no-empty-function */
/* eslint-disable no-empty-function */

'use strict';

Expand All @@ -31,56 +31,20 @@ var isCubeNumber = require( './../lib' );

// MAIN //

bench( pkg+'::primitives', function benchmark( b ) {
bench( pkg+'::primitives,true', function benchmark( b ) {
var values;
var bool;
var i;

values = [
'5',
5,
4,
0.5,
1.0,
0.0,
3.14,
-5,
-4,
NaN,
true,
false,
null,
void 0
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isCubeNumber( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::objects', function benchmark( b ) {
var values;
var bool;
var i;

values = [
[],
{},
function noop() {},
new Number( 8.0 ),
new Number( 0.5 ),
new Number( NaN ),
new Number( 3.14 )
-4
];

b.tic();
Expand All @@ -98,21 +62,13 @@ bench( pkg+'::objects', function benchmark( b ) {
b.end();
});

bench( pkg+'::primitives:isPrimitive', function benchmark( b ) {
bench( pkg+'::primitives,false', function benchmark( b ) {
var values;
var bool;
var i;

values = [
'5',
5,
4,
3.14,
0.5,
1.0,
0.0,
-5,
-4,
NaN,
true,
false,
Expand All @@ -122,7 +78,7 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isCubeNumber.isPrimitive( values[ i % values.length ] );
bool = isCubeNumber( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
Expand All @@ -135,15 +91,12 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) {
b.end();
});

bench( pkg+'::objects:isPrimitive', function benchmark( b ) {
bench( pkg+'::objects,true', function benchmark( b ) {
var values;
var bool;
var i;

values = [
[],
{},
function noop() {},
new Number( 8.0 ),
new Number( 0.5 ),
new Number( NaN ),
Expand All @@ -152,44 +105,7 @@ bench( pkg+'::objects:isPrimitive', function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isCubeNumber.isPrimitive( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});

bench( pkg+'::primitives:isObject', function benchmark( b ) {
var values;
var bool;
var i;

values = [
'5',
5,
4,
3.14,
0.5,
1.0,
0.0,
-5,
-4,
NaN,
true,
false,
null,
void 0
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isCubeNumber.isObject( values[ i % values.length ] );
bool = isCubeNumber( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
Expand All @@ -202,24 +118,20 @@ bench( pkg+'::primitives:isObject', function benchmark( b ) {
b.end();
});

bench( pkg+'::objects:isObject', function benchmark( b ) {
bench( pkg+'::objects,false', function benchmark( b ) {
var values;
var bool;
var i;

values = [
[],
{},
function noop() {},
new Number( 8.0 ),
new Number( 0.5 ),
new Number( NaN ),
new Number( 3.14 )
function noop() {}
];

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isCubeNumber.isObject( values[ i % values.length ] );
bool = isCubeNumber( values[ i % values.length ] );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
Expand Down