Skip to content

Commit ea7f876

Browse files
committed
bench: refactor to use dynamic memory allocation in math/strided/special/smskdeg2rad
Signed-off-by: Yohan Park <[email protected]>
1 parent 29fc92b commit ea7f876

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/node_modules/@stdlib/math/strided/special/smskdeg2rad/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-
float x[ len ];
120-
float y[ len ];
118+
uint8_t *m;
119+
float *x;
120+
float *y;
121121
double t;
122122
int i;
123123

124+
m = (uint8_t *) malloc( len * sizeof( uint8_t ) );
125+
x = (float *) malloc( len * sizeof( float ) );
126+
y = (float *) malloc( len * sizeof( float ) );
124127
for ( i = 0; i < len; i++ ) {
125128
x[ i ] = rand_uniformf( -180.0f, 180.0f );
126129
y[ i ] = 0.0f;
@@ -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)