Skip to content

Commit 2473d1e

Browse files
Omar-2718kgryte
andauthored
bench: refactor to use dynamic memory allocation in strided/base/dmskmap2
PR-URL: #9354 Ref: #8643 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 4cc58f5 commit 2473d1e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,18 @@ static double add( const double x, const double y ) {
107107
* @return elapsed time in seconds
108108
*/
109109
static double benchmark( int iterations, int len ) {
110-
uint8_t m[ len ];
111110
double elapsed;
112-
double x[ len ];
113-
double y[ len ];
114-
double z[ len ];
111+
uint8_t *m;
112+
double *x;
113+
double *y;
114+
double *z;
115115
double t;
116116
int i;
117117

118+
m = (uint8_t *)malloc( len * sizeof( uint8_t ) );
119+
x = (double *)malloc( len * sizeof( double ) );
120+
y = (double *)malloc( len * sizeof( double ) );
121+
z = (double *)malloc( len * sizeof( double ) );
118122
for ( i = 0; i < len; i++ ) {
119123
x[ i ] = ( rand_double()*200.0 ) - 100.0;
120124
y[ i ] = ( rand_double()*200.0 ) - 100.0;
@@ -133,6 +137,10 @@ static double benchmark( int iterations, int len ) {
133137
if ( z[ i%len ] != z[ i%len ] ) {
134138
printf( "should not return NaN\n" );
135139
}
140+
free( m );
141+
free( x );
142+
free( y );
143+
free( z );
136144
return elapsed;
137145
}
138146

0 commit comments

Comments
 (0)