Skip to content

Commit f283500

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

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ static float rand_float( void ) {
9797
*/
9898
static double benchmark1( int iterations, int len ) {
9999
stdlib_complex64_t alpha;
100-
float x[ len*2 ];
100+
float *x;
101101
double elapsed;
102102
double t;
103103
int i;
104104

105+
x = (float *) malloc( len * 2 * sizeof(float) );
106+
105107
alpha = stdlib_complex64( 1.0f, 0.0f );
106108
for ( i = 0; i < len*2; i += 2 ) {
107109
x[ i ] = ( rand_float()*2.0f ) - 1.0f;
@@ -120,6 +122,8 @@ static double benchmark1( int iterations, int len ) {
120122
if ( x[ 0 ] != x[ 0 ] ) {
121123
printf( "should not return NaN\n" );
122124
}
125+
126+
free( x );
123127
return elapsed;
124128
}
125129

@@ -132,11 +136,11 @@ static double benchmark1( int iterations, int len ) {
132136
*/
133137
static double benchmark2( int iterations, int len ) {
134138
stdlib_complex64_t alpha;
135-
float x[ len*2 ];
139+
float *x;
136140
double elapsed;
137141
double t;
138142
int i;
139-
143+
x = (float *) malloc( len * 2 * sizeof(float) );
140144
alpha = stdlib_complex64( 1.0f, 0.0f );
141145
for ( i = 0; i < len*2; i += 2 ) {
142146
x[ i ] = ( rand_float()*2.0f ) - 1.0f;
@@ -155,6 +159,8 @@ static double benchmark2( int iterations, int len ) {
155159
if ( x[ 0 ] != x[ 0 ] ) {
156160
printf( "should not return NaN\n" );
157161
}
162+
163+
free( x );
158164
return elapsed;
159165
}
160166

0 commit comments

Comments
 (0)