Skip to content

Commit 8ffc2c4

Browse files
committed
bench: refactor to use dynamic memory allocation in strided/base/smap2
1 parent 32d9f09 commit 8ffc2c4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/node_modules/@stdlib/strided/base/smap2/benchmark/c/benchmark.length.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ static float addf( const float x, const float y ) {
107107
*/
108108
static double benchmark( int iterations, int len ) {
109109
double elapsed;
110-
float x[ len ];
111-
float y[ len ];
112-
float z[ len ];
110+
float *x;
111+
float *y;
112+
float *z;
113113
double t;
114114
int i;
115115

116+
x = (float *)malloc( len * sizeof( float ) );
117+
y = (float *)malloc( len * sizeof( float ) );
118+
z = (float *)malloc( len * sizeof( float ) );
116119
for ( i = 0; i < len; i++ ) {
117120
x[ i ] = ( rand_float()*200.0f ) - 100.0f;
118121
y[ i ] = ( rand_float()*200.0f ) - 100.0f;
@@ -130,6 +133,9 @@ static double benchmark( int iterations, int len ) {
130133
if ( z[ i%len ] != z[ i%len ] ) {
131134
printf( "should not return NaN\n" );
132135
}
136+
free( x );
137+
free( y );
138+
free( z );
133139
return elapsed;
134140
}
135141

0 commit comments

Comments
 (0)