Skip to content

Commit 73de076

Browse files
fix: update benchmark to use float instead of double for consistency
--- 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 --- --- 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: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - 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 9bbf5e7 commit 73de076

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/node_modules/@stdlib/blas/ext/base/ssort2hp/benchmark/c/benchmark.unsorted_random.length.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ static double tic( void ) {
8282
*
8383
* @return random number
8484
*/
85-
static double rand_double( void ) {
85+
static double rand_float( void ) {
8686
int r = rand();
87-
return (double)r / ( (double)RAND_MAX + 1.0 );
87+
return (float)r / ( (float)RAND_MAX + 1.0f );
8888
}
8989

9090
/**
@@ -96,20 +96,20 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
99-
double *x;
100-
double *y;
10199
double t;
100+
float *x;
101+
float *y;
102102
int i;
103103

104-
x = ( double * )malloc( len * sizeof(double) );
105-
y = ( double * )malloc( len * sizeof(double) );
104+
x = ( float * )malloc( len * sizeof(float) );
105+
y = ( float * )malloc( len * sizeof(float) );
106106
for ( i = 0; i < len; i++ ) {
107-
x[ i ] = ( rand_double()*20.0 ) - 10.0;
108-
y[ i ] = ( rand_double()*20.0 ) - 10.0;
107+
x[ i ] = ( rand_float()*20.0f ) - 10.0f;
108+
y[ i ] = ( rand_float()*20.0f ) - 10.0f;
109109
}
110110
t = tic();
111111
for ( i = 0; i < iterations; i++ ) {
112-
stdlib_strided_ssort2hp( len, 1.0, x, 1, y, 1 );
112+
stdlib_strided_ssort2hp( len, 1.0f, x, 1, y, 1 );
113113
if ( y[ 0 ] != y[ 0 ] ) {
114114
printf( "should not return NaN\n" );
115115
break;
@@ -133,20 +133,20 @@ static double benchmark1( int iterations, int len ) {
133133
*/
134134
static double benchmark2( int iterations, int len ) {
135135
double elapsed;
136-
double *x;
137-
double *y;
138136
double t;
137+
float *x;
138+
float *y;
139139
int i;
140140

141-
x = (double *)malloc( len * sizeof(double) );
142-
y = (double *)malloc( len * sizeof(double) );
141+
x = (float *)malloc( len * sizeof(float) );
142+
y = (float *)malloc( len * sizeof(float) );
143143
for ( i = 0; i < len; i++ ) {
144-
x[ i ] = ( rand_double()*20.0 ) - 10.0;
145-
y[ i ] = ( rand_double()*20.0 ) - 10.0;
144+
x[ i ] = ( rand_float()*20.0f ) - 10.0f;
145+
y[ i ] = ( rand_float()*20.0f ) - 10.0f;
146146
}
147147
t = tic();
148148
for ( i = 0; i < iterations; i++ ) {
149-
stdlib_strided_ssort2hp_ndarray( len, 1.0, x, 1, 0, y, 1, 0 );
149+
stdlib_strided_ssort2hp_ndarray( len, 1.0f, x, 1, 0, y, 1, 0 );
150150
if ( y[ 0 ] != y[ 0 ] ) {
151151
printf( "should not return NaN\n" );
152152
break;

0 commit comments

Comments
 (0)