diff --git a/CHANGELOG.md b/CHANGELOG.md index c16c3b36..e3e832ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-09-09) +## Unreleased (2024-09-11)
@@ -131,9 +131,11 @@ ### Contributors -A total of 1 person contributed to this release. Thank you to this contributor: +A total of 3 people contributed to this release. Thank you to the following contributors: - Athan Reines +- Philipp Burckhardt +- Soumajit Chatterjee
@@ -145,6 +147,7 @@ A total of 1 person contributed to this release. Thank you to this contributor:
+- [`1f6fc8b`](https://github.com/stdlib-js/stdlib/commit/1f6fc8b5b99837f9d8b378413298f7544f1cb38e) - **bench:** update benchmarks to measure affirmative/negative test values _(by Soumajit Chatterjee, Philipp Burckhardt)_ - [`e97215f`](https://github.com/stdlib-js/stdlib/commit/e97215fbf9f4d1ec8548086f78ed04a0ec80a43f) - **feat:** add `hasBtoaSupport` to namespace _(by Athan Reines)_ - [`33219ce`](https://github.com/stdlib-js/stdlib/commit/33219cecbc347a85b4bb9659d00005fe7b5a6e64) - **feat:** add `assert/has-btoa-support` _(by Athan Reines)_ - [`80b8061`](https://github.com/stdlib-js/stdlib/commit/80b8061c5888d04dcaa48f0363669ba2606856df) - **feat:** add `hasAtobSupport` to namespace _(by Athan Reines)_ diff --git a/is-cube-number/benchmark/benchmark.js b/is-cube-number/benchmark/benchmark.js index 9bf98634..bc787314 100644 --- a/is-cube-number/benchmark/benchmark.js +++ b/is-cube-number/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'; @@ -31,26 +31,51 @@ 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 = [ + 8, + 64, + 1, + -27, + -8, + 125, + -1000, + 27 + ]; + + 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+'::primitives,false', 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 + void 0, + -6, + 7.25 ]; b.tic(); @@ -68,19 +93,51 @@ 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 Number( 8 ), + new Number( 64 ), + new Number( 1 ), + new Number( -27 ), + new Number( -8 ), + new Number( 125 ), + new Number( -1000 ), + new Number( 27 ) + ]; + + 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,false', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Number( 5 ), + new Number( NaN ), + new Number( 3.14 ), + new Number( -6 ), + new Number( 7.25 ), [], {}, - function noop() {}, - new Number( 8.0 ), - new Number( 0.5 ), - new Number( NaN ), - new Number( 3.14 ) + function noop() {} ]; b.tic(); @@ -98,26 +155,51 @@ 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 = [ + 8, + 64, + 1, + -27, + -8, + 125, + -1000, + 27 + ]; + + 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:isPrimitive,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, null, - void 0 + void 0, + -6, + 7.25 ]; b.tic(); @@ -135,19 +217,23 @@ 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; values = [ + new Number( 8 ), + new Number( 64 ), + new Number( 1 ), + new Number( -27 ), + new Number( -8 ), + new Number( 125 ), + new Number( -1000 ), + new Number( 27 ), [], {}, - function noop() {}, - new Number( 8.0 ), - new Number( 0.5 ), - new Number( NaN ), - new Number( 3.14 ) + function noop() {} ]; b.tic(); @@ -165,26 +251,51 @@ 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; values = [ '5', - 5, - 4, - 3.14, - 0.5, - 1.0, - 0.0, - -5, - -4, NaN, true, false, null, - void 0 + void 0, + -6, + 7.25 + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = isCubeNumber.isObject( 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:isObject,true', function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + new Number( 8 ), + new Number( 64 ), + new Number( 1 ), + new Number( -27 ), + new Number( -8 ), + new Number( 125 ), + new Number( -1000 ), + new Number( 27 ) ]; b.tic(); @@ -202,19 +313,20 @@ bench( pkg+'::primitives:isObject', function benchmark( b ) { b.end(); }); -bench( pkg+'::objects:isObject', function benchmark( b ) { +bench( pkg+'::objects:isObject,false', function benchmark( b ) { var values; var bool; var i; values = [ + new Number( 5 ), + new Number( NaN ), + new Number( 3.14 ), + new Number( -6 ), + new Number( 7.25 ), [], {}, - function noop() {}, - new Number( 8.0 ), - new Number( 0.5 ), - new Number( NaN ), - new Number( 3.14 ) + function noop() {} ]; b.tic();