Skip to content

Commit 41272b6

Browse files
committed
bench: move random number generation outside the benchmarking loops
--- 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 92134ea commit 41272b6

File tree

1 file changed

+9
-2
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark

1 file changed

+9
-2
lines changed

lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24+
var Float64Array = require( '@stdlib/array/float64' );
2425
var uniform = require( '@stdlib/random/base/uniform' );
2526
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2627
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -31,14 +32,20 @@ var entropy = require( './../lib' );
3132
// MAIN //
3233

3334
bench( pkg, function benchmark( b ) {
35+
var len;
3436
var k;
3537
var y;
3638
var i;
3739

40+
len = 100;
41+
k = new Float64Array( len );
42+
for ( i = 0; i < len; i++ ) {
43+
k[ i ] = uniform( EPS, 20.0 );
44+
}
45+
3846
b.tic();
3947
for ( i = 0; i < b.iterations; i++ ) {
40-
k = uniform( EPS, 20.0 );
41-
y = entropy( k );
48+
y = entropy( k[ i % len ] );
4249
if ( isnan( y ) ) {
4350
b.fail( 'should not return NaN' );
4451
}

0 commit comments

Comments
 (0)