Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Mar 3, 2024
1 parent b314cc1 commit ee3fc55
Showing 1 changed file with 109 additions and 15 deletions.
124 changes: 109 additions & 15 deletions is-boolean/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 @@ -30,7 +30,32 @@ var isBoolean = require( './../lib' );

// MAIN //

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

values = [
true,
false
];

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

bench( pkg+'::primitives,false', function benchmark( b ) {
var values;
var bool;
var i;
Expand All @@ -39,8 +64,6 @@ bench( pkg+'::primitives', function benchmark( b ) {
'5',
5,
NaN,
true,
false,
null,
void 0
];
Expand All @@ -60,16 +83,40 @@ bench( pkg+'::primitives', function benchmark( b ) {
b.end();
});

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

values = [
new Boolean( true ),
new Boolean( false )
];

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

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

values = [
[],
{},
function noop() {},
new Boolean( true )
function noop() {}
];

b.tic();
Expand All @@ -87,7 +134,32 @@ bench( pkg+'::objects', function benchmark( b ) {
b.end();
});

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

values = [
true,
false
];

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

bench( pkg+'::primitives:isPrimitive,false', function benchmark( b ) {
var values;
var bool;
var i;
Expand All @@ -96,8 +168,6 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) {
'5',
5,
NaN,
true,
false,
null,
void 0
];
Expand All @@ -117,7 +187,7 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) {
b.end();
});

bench( pkg+'::objects:isPrimitive', function benchmark( b ) {
bench( pkg+'::objects:isPrimitive,false', function benchmark( b ) {
var values;
var bool;
var i;
Expand All @@ -144,7 +214,7 @@ bench( pkg+'::objects:isPrimitive', function benchmark( b ) {
b.end();
});

bench( pkg+'::primitives:isObject', function benchmark( b ) {
bench( pkg+'::primitives:isObject,false', function benchmark( b ) {
var values;
var bool;
var i;
Expand Down Expand Up @@ -174,16 +244,40 @@ bench( pkg+'::primitives:isObject', function benchmark( b ) {
b.end();
});

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

values = [
new Boolean( true ),
new Boolean( false )
];

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

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

values = [
[],
{},
function noop() {},
new Boolean( true )
function noop() {}
];

b.tic();
Expand Down

0 comments on commit ee3fc55

Please sign in to comment.