Skip to content

Commit 8f730a7

Browse files
committed
bench: refactor to use dynamic memory allocation in 'blas/ext/base/dnansumkbn'
--- 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 8f730a7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/node_modules/@stdlib/blas/ext/base/dnansumkbn/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
@@ -121,6 +122,7 @@ static double benchmark1( int iterations, int len ) {
121122
if ( v != v ) {
122123
printf( "should not return NaN\n" );
123124
}
125+
free( x );
124126
return elapsed;
125127
}
126128

@@ -133,11 +135,12 @@ static double benchmark1( int iterations, int len ) {
133135
*/
134136
static double benchmark2( int iterations, int len ) {
135137
double elapsed;
136-
double x[ len ];
138+
double *x;
137139
double v;
138140
double t;
139141
int i;
140142

143+
x = (double *)malloc( len * sizeof( double ) );
141144
for ( i = 0; i < len; i++ ) {
142145
if ( rand_double() < 0.2 ) {
143146
x[ i ] = 0.0 / 0.0; // NaN
@@ -158,6 +161,7 @@ static double benchmark2( int iterations, int len ) {
158161
if ( v != v ) {
159162
printf( "should not return NaN\n" );
160163
}
164+
free( x );
161165
return elapsed;
162166
}
163167

0 commit comments

Comments
 (0)