Skip to content

Commit f0f8a70

Browse files
committed
bench: refactor to use dynamic memory allocation in blas/ext/base/dfill
--- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent be4ce52 commit f0f8a70

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ 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 t;
101101
int i;
102102

103+
x = (double *) malloc( len * sizeof( double ) );
103104
for ( i = 0; i < len; i++ ) {
104105
x[ i ] = ( rand_double()*200.0 ) - 100.0;
105106
}
@@ -115,6 +116,7 @@ static double benchmark1( int iterations, int len ) {
115116
if ( x[ 0 ] != x[ 0 ] ) {
116117
printf( "should not return NaN\n" );
117118
}
119+
free( x );
118120
return elapsed;
119121
}
120122

@@ -127,10 +129,11 @@ static double benchmark1( int iterations, int len ) {
127129
*/
128130
static double benchmark2( int iterations, int len ) {
129131
double elapsed;
130-
double x[ len ];
132+
double *x;
131133
double t;
132134
int i;
133135

136+
x = (double *) malloc( len * sizeof( double ) );
134137
for ( i = 0; i < len; i++ ) {
135138
x[ i ] = ( rand_double()*200.0 ) - 100.0;
136139
}
@@ -146,6 +149,7 @@ static double benchmark2( int iterations, int len ) {
146149
if ( x[ 0 ] != x[ 0 ] ) {
147150
printf( "should not return NaN\n" );
148151
}
152+
free( x );
149153
return elapsed;
150154
}
151155

0 commit comments

Comments
 (0)