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 Sep 11, 2024
1 parent d80053e commit f69cf34
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 51 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-09-09)
## Unreleased (2024-09-11)

<section class="packages">

Expand Down Expand Up @@ -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

</section>

Expand All @@ -145,6 +147,7 @@ A total of 1 person contributed to this release. Thank you to this contributor:

<details>

- [`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)_
Expand Down
210 changes: 161 additions & 49 deletions 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,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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit f69cf34

Please sign in to comment.