Skip to content

Commit 975f9f6

Browse files
authored
bench: refactor to use dynamic memory allocation in blas/ext/base/sapx
PR-URL: #9176 Ref: #8643 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 30ac15d commit 975f9f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ 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
double t;
101101
int i;
102102

103+
x = (float *)malloc( len * sizeof( float ) );
103104
for ( i = 0; i < len; i++ ) {
104105
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
105106
}
@@ -116,6 +117,7 @@ static double benchmark1( int iterations, int len ) {
116117
if ( x[ 0 ] != x[ 0 ] ) {
117118
printf( "should not return NaN\n" );
118119
}
120+
free( x );
119121
return elapsed;
120122
}
121123

@@ -128,10 +130,11 @@ static double benchmark1( int iterations, int len ) {
128130
*/
129131
static double benchmark2( int iterations, int len ) {
130132
double elapsed;
131-
float x[ len ];
133+
float *x;
132134
double t;
133135
int i;
134136

137+
x = (float *)malloc( len * sizeof( float ) );
135138
for ( i = 0; i < len; i++ ) {
136139
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
137140
}
@@ -148,6 +151,7 @@ static double benchmark2( int iterations, int len ) {
148151
if ( x[ 0 ] != x[ 0 ] ) {
149152
printf( "should not return NaN\n" );
150153
}
154+
free( x );
151155
return elapsed;
152156
}
153157

0 commit comments

Comments
 (0)