Skip to content

Commit d78f0bf

Browse files
committed
bench: use dynamic memory reallocation
--- 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 abaf09b commit d78f0bf

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,16 @@ static double benchmark1( int iterations, int N ) {
100100
stdlib_complex64_t alpha;
101101
stdlib_complex64_t beta;
102102
double elapsed;
103-
float A[ N*N*2 ];
104-
float x[ N*2 ];
105-
float y[ N*2 ];
103+
float *A;
104+
float *x;
105+
float *y;
106106
double t;
107107
int i;
108108
int j;
109109

110+
A = (float *)malloc( N * N * 2 * sizeof( float ) );
111+
x = (float *)malloc( N * 2 * sizeof( float ) );
112+
y = (float *)malloc( N * 2 * sizeof( float ) );
110113
alpha = stdlib_complex64( 0.5f, 0.5f );
111114
beta = stdlib_complex64( 0.5f, -0.5f );
112115

@@ -131,6 +134,9 @@ static double benchmark1( int iterations, int N ) {
131134
if ( y[ i%N ] != y[ i%N ] ) {
132135
printf( "should not return NaN\n" );
133136
}
137+
free( A );
138+
free( x );
139+
free( y );
134140
return elapsed;
135141
}
136142

@@ -145,13 +151,16 @@ static double benchmark2( int iterations, int N ) {
145151
stdlib_complex64_t alpha;
146152
stdlib_complex64_t beta;
147153
double elapsed;
148-
float A[ N*N*2 ];
149-
float x[ N*2 ];
150-
float y[ N*2 ];
154+
float *A;
155+
float *x;
156+
float *y;
151157
double t;
152158
int i;
153159
int j;
154160

161+
A = (float *)malloc( N * N * 2 * sizeof( float ) );
162+
x = (float *)malloc( N * 2 * sizeof( float ) );
163+
y = (float *)malloc( N * 2 * sizeof( float ) );
155164
alpha = stdlib_complex64( 0.5f, 0.5f );
156165
beta = stdlib_complex64( 0.5f, -0.5f );
157166

@@ -176,6 +185,9 @@ static double benchmark2( int iterations, int N ) {
176185
if ( y[ i%N ] != y[ i%N ] ){
177186
printf( "should not return NaN\n" );
178187
}
188+
free( A );
189+
free( x );
190+
free( y );
179191
return elapsed;
180192
}
181193

0 commit comments

Comments
 (0)