Skip to content

Commit 0eb946c

Browse files
committed
bench: refactor to use dynamic memory allocation in blas/ext/base/dnansum
--- 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: missing_dependencies - 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 e57055b commit 0eb946c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ static double rand_double( void ) {
9696
*/
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
99-
double x[ len ];
99+
double *x;
100100
double v;
101101
double t;
102102
int i;
103103

104+
x = (double *)malloc( len * sizeof( double ) );
104105
for ( i = 0; i < len; i++ ) {
105106
if ( rand_double() < 0.2 ) {
106107
x[ i ] = 0.0 / 0.0; // NaN
@@ -122,6 +123,7 @@ static double benchmark1( int iterations, int len ) {
122123
if ( v != v ) {
123124
printf( "should not return NaN\n" );
124125
}
126+
free( x );
125127
return elapsed;
126128
}
127129

@@ -134,11 +136,12 @@ static double benchmark1( int iterations, int len ) {
134136
*/
135137
static double benchmark2( int iterations, int len ) {
136138
double elapsed;
137-
double x[ len ];
139+
double *x;
138140
double v;
139141
double t;
140142
int i;
141143

144+
x = (double *)malloc( len * sizeof( double ) );
142145
for ( i = 0; i < len; i++ ) {
143146
if ( rand_double() < 0.2 ) {
144147
x[ i ] = 0.0 / 0.0; // NaN
@@ -160,6 +163,7 @@ static double benchmark2( int iterations, int len ) {
160163
if ( v != v ) {
161164
printf( "should not return NaN\n" );
162165
}
166+
free( x );
163167
return elapsed;
164168
}
165169

0 commit comments

Comments
 (0)