Skip to content

Commit 7c2e6b4

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: na - 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: passed - 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 ---
1 parent 72ccb45 commit 7c2e6b4

File tree

1 file changed

+6
-3
lines changed
  • lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native

1 file changed

+6
-3
lines changed

lib/node_modules/@stdlib/math/base/special/roundsd/benchmark/c/native/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,19 @@ static double rand_double( void ) {
9090
* @return elapsed time in seconds
9191
*/
9292
static double benchmark( void ) {
93+
double v[ 100 ];
9394
double elapsed;
9495
double t;
95-
double v;
9696
double y;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
v[ i ] = ( 1000.0*rand_double() ) - 500.0;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
v = ( 1000.0*rand_double() ) - 500.0;
102-
y = stdlib_base_roundsd( v, 5, 10 );
105+
y = stdlib_base_roundsd( v[ i%100 ], 5, 10 );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

0 commit comments

Comments
 (0)