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 Apr 20, 2022
1 parent 4d57129 commit 2572c44
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions size-of/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,41 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var hypot = require( '@stdlib/math/base/special/hypot' );
var pkg = require( './../package.json' ).name;
var sizeOf = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var x;
var y;
var z;
var values;
var s;
var i;

values = [
'float64',
'float32',
'float16',
'int32',
'uint32',
'int16',
'uint16',
'int8',
'uint8',
'uint8c',
'complex128',
'complex64'
];
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*100.0 ) - 50.0;
y = ( randu()*100.0 ) - 50.0;
z = hypot( x, y );
if ( isnan( z ) ) {
s = sizeOf( values[ i%values.length ] );
if ( isnan( s ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( z ) ) {
if ( isnan( s ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
Expand Down

0 comments on commit 2572c44

Please sign in to comment.