Skip to content

Commit 3633d58

Browse files
authored
bench: refactor to use dynamic memory allocation
PR-URL: #9218 Ref: #8643 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent d53a54e commit 3633d58

File tree

1 file changed

+12
-4
lines changed
  • lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c

1 file changed

+12
-4
lines changed

lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c/benchmark.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ static double tic( void ) {
8888
*/
8989
static double benchmark1( int iterations, int N ) {
9090
double elapsed;
91-
float A[ N*N ];
92-
float x[ N ];
91+
float *A;
92+
float *x;
9393
double t;
9494
int i;
9595

96+
x = (float *)malloc( N * sizeof( float ) );
97+
A = (float *)malloc( N * N * sizeof( float ) );
9698
stdlib_strided_sfill( N, 1.0f, x, 1 );
9799
stdlib_strided_sfill( N*N, 1.0f, A, 1 );
98100
t = tic();
@@ -107,6 +109,8 @@ static double benchmark1( int iterations, int N ) {
107109
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
108110
printf( "should not return NaN\n" );
109111
}
112+
free( x );
113+
free( A );
110114
return elapsed;
111115
}
112116

@@ -119,11 +123,13 @@ static double benchmark1( int iterations, int N ) {
119123
*/
120124
static double benchmark2( int iterations, int N ) {
121125
double elapsed;
122-
float A[ N*N ];
123-
float x[ N ];
126+
float *A;
127+
float *x;
124128
double t;
125129
int i;
126130

131+
x = (float *)malloc( N * sizeof( float ) );
132+
A = (float *)malloc( N * N * sizeof( float ) );
127133
stdlib_strided_sfill( N, 1.0f, x, 1 );
128134
stdlib_strided_sfill( N*N, 1.0f, A, 1 );
129135
t = tic();
@@ -138,6 +144,8 @@ static double benchmark2( int iterations, int N ) {
138144
if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) {
139145
printf( "should not return NaN\n" );
140146
}
147+
free( x );
148+
free( A );
141149
return elapsed;
142150
}
143151

0 commit comments

Comments
 (0)