|
| 1 | +/** |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2026 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +'use strict'; |
| 20 | + |
| 21 | +// MODULES // |
| 22 | + |
| 23 | +var bench = require( '@stdlib/bench' ); |
| 24 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 25 | +var toFloat16 = require( './../../../../../float64/base/to-float16' ); |
| 26 | +var map = require( '@stdlib/array/base/map' ); |
| 27 | +var naryFunction = require( '@stdlib/utils/nary-function' ); |
| 28 | +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; |
| 29 | +var pkg = require( './../package.json' ).name; |
| 30 | +var isnan = require( './../lib' ); |
| 31 | + |
| 32 | + |
| 33 | +// MAIN // |
| 34 | + |
| 35 | +bench( pkg, function benchmark( b ) { |
| 36 | + var x; |
| 37 | + var y; |
| 38 | + var i; |
| 39 | + |
| 40 | + x = map( uniform( 100, -5.0e6, 5.0e6 ), naryFunction( toFloat16, 1 ) ); |
| 41 | + |
| 42 | + b.tic(); |
| 43 | + for ( i = 0; i < b.iterations; i++ ) { |
| 44 | + y = isnan( x[ i%x.length ] ); |
| 45 | + if ( typeof y !== 'boolean' ) { |
| 46 | + b.fail( 'should return a boolean' ); |
| 47 | + } |
| 48 | + } |
| 49 | + b.toc(); |
| 50 | + if ( !isBoolean( y ) ) { |
| 51 | + b.fail( 'should return a boolean' ); |
| 52 | + } |
| 53 | + b.pass( 'benchmark finished' ); |
| 54 | + b.end(); |
| 55 | +}); |
0 commit comments