Skip to content

Commit 8ac43f8

Browse files
committed
refactor: update benchmarks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fbedc02 commit 8ac43f8

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • lib/node_modules/@stdlib/number/float16/base/to-binary-string/benchmark

lib/node_modules/@stdlib/number/float16/base/to-binary-string/benchmark/benchmark.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2626
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
27+
var map = require( '@stdlib/array/base/map' );
28+
var naryFunction = require( '@stdlib/utils/nary-function' );
2729
var pkg = require( './../package.json' ).name;
2830
var toBinaryString = require( './../lib' );
2931

@@ -35,10 +37,11 @@ bench( pkg, function benchmark( b ) {
3537
var y;
3638
var i;
3739

40+
x = map( uniform( 100, -5.0e4, 5.0e4 ), naryFunction( toFloat16, 1 ) );
41+
3842
b.tic();
3943
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*1.0e7 ) - 5.0e6;
41-
y = toBinaryString( toFloat16( x ) );
44+
y = toBinaryString( x[ i%x.length ] );
4245
if ( typeof y !== 'string' ) {
4346
b.fail( 'should return a string' );
4447
}

0 commit comments

Comments
 (0)