Skip to content

Commit 96c0633

Browse files
committed
refactor: convert static to dynamic allocation in benchmark
Signed-off-by: thzthix <[email protected]>
1 parent 29fc92b commit 96c0633

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/node_modules/@stdlib/math/strided/special/dmskrsqrt/benchmark/c/benchmark.length.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,15 @@ float rand_uniformf( float a, float b ) {
115115
*/
116116
static double benchmark( int iterations, int len ) {
117117
double elapsed;
118-
uint8_t m[ len ];
119-
double x[ len ];
120-
double y[ len ];
118+
uint8_t *m;
119+
double *x;
120+
double *y;
121121
double t;
122122
int i;
123123

124+
m = (uint8_t *)malloc( len *sizeof( uint8_t ) );
125+
x = (double *)malloc( len * sizeof( double ) );
126+
y = (double *)malloc( len * sizeof( double ) );
124127
for ( i = 0; i < len; i++ ) {
125128
x[ i ] = rand_uniform( 0.0, 200.0 );
126129
y[ i ] = 0.0;
@@ -138,6 +141,9 @@ static double benchmark( int iterations, int len ) {
138141
if ( y[ 0 ] != y[ 0 ] ) {
139142
printf( "should not return NaN\n" );
140143
}
144+
free( m );
145+
free( x );
146+
free( y );
141147
return elapsed;
142148
}
143149

0 commit comments

Comments
 (0)