Skip to content

Commit 502f3cc

Browse files
bench: refactor to use dynamic memory allocation in blas/ext/base/scusumors
--- 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 14c965b commit 502f3cc

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

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

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

104+
x = (float *) malloc( len * sizeof( float ) );
105+
y = (float *) malloc( len * sizeof( float ) );
104106
for ( i = 0; i < len; i++ ) {
105107
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
106108
y[ i ] = 0.0f;
@@ -118,6 +120,8 @@ static double benchmark1( int iterations, int len ) {
118120
if ( y[ len-1 ] != y[ len-1 ] ) {
119121
printf( "should not return NaN\n" );
120122
}
123+
free( x );
124+
free( y );
121125
return elapsed;
122126
}
123127

@@ -130,11 +134,13 @@ static double benchmark1( int iterations, int len ) {
130134
*/
131135
static double benchmark2( int iterations, int len ) {
132136
double elapsed;
133-
float x[ len ];
134-
float y[ len ];
137+
float *x;
138+
float *y;
135139
double t;
136140
int i;
137141

142+
x = (float *) malloc( len * sizeof( float ) );
143+
y = (float *) malloc( len * sizeof( float ) );
138144
for ( i = 0; i < len; i++ ) {
139145
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
140146
y[ i ] = 0.0f;
@@ -152,6 +158,8 @@ static double benchmark2( int iterations, int len ) {
152158
if ( y[ len-1 ] != y[ len-1 ] ) {
153159
printf( "should not return NaN\n" );
154160
}
161+
free( x );
162+
free( y );
155163
return elapsed;
156164
}
157165

0 commit comments

Comments
 (0)