Skip to content

Commit 1d8eb86

Browse files
committed
bench: refactor to use dynamic memory allocation in blas/base/snrm2
--- 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 f86a874 commit 1d8eb86

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/node_modules/@stdlib/blas/base/snrm2/benchmark/c/benchmark.length.c

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

104+
x = (float *)malloc( len * sizeof( float ) );
104105
for ( i = 0; i < len; i++ ) {
105106
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
106107
}
@@ -117,6 +118,7 @@ static double benchmark1( int iterations, int len ) {
117118
if ( z != z ) {
118119
printf( "should not return NaN\n" );
119120
}
121+
free( x );
120122
return elapsed;
121123
}
122124

@@ -129,11 +131,12 @@ static double benchmark1( int iterations, int len ) {
129131
*/
130132
static double benchmark2( int iterations, int len ) {
131133
double elapsed;
132-
float x[ len ];
134+
float *x;
133135
float z;
134136
double t;
135137
int i;
136138

139+
x = (float *)malloc( len * sizeof( float ) );
137140
for ( i = 0; i < len; i++ ) {
138141
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
139142
}
@@ -150,6 +153,7 @@ static double benchmark2( int iterations, int len ) {
150153
if ( z != z ) {
151154
printf( "should not return NaN\n" );
152155
}
156+
free( x );
153157
return elapsed;
154158
}
155159

0 commit comments

Comments
 (0)