From ee3fc55e5418b78fa86f3f31bc1a68b7e43ddaab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 3 Mar 2024 21:26:09 +0000 Subject: [PATCH] Auto-generated commit --- is-boolean/benchmark/benchmark.js | 124 ++++++++++++++++++++++++++---- 1 file changed, 109 insertions(+), 15 deletions(-) diff --git a/is-boolean/benchmark/benchmark.js b/is-boolean/benchmark/benchmark.js index 3ae451e9..c79db99f 100644 --- a/is-boolean/benchmark/benchmark.js +++ b/is-boolean/benchmark/benchmark.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable no-new-wrappers, no-empty-function */ +/* eslint-disable no-empty-function */ 'use strict'; @@ -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; @@ -39,8 +64,6 @@ bench( pkg+'::primitives', function benchmark( b ) { '5', 5, NaN, - true, - false, null, void 0 ]; @@ -60,7 +83,32 @@ 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; @@ -68,8 +116,7 @@ bench( pkg+'::objects', function benchmark( b ) { values = [ [], {}, - function noop() {}, - new Boolean( true ) + function noop() {} ]; b.tic(); @@ -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; @@ -96,8 +168,6 @@ bench( pkg+'::primitives:isPrimitive', function benchmark( b ) { '5', 5, NaN, - true, - false, null, void 0 ]; @@ -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; @@ -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; @@ -174,7 +244,32 @@ 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; @@ -182,8 +277,7 @@ bench( pkg+'::objects:isObject', function benchmark( b ) { values = [ [], {}, - function noop() {}, - new Boolean( true ) + function noop() {} ]; b.tic();