Skip to content

Commit 4948ecc

Browse files
authored
bench: refactor to use dynamic memory allocation in math/strided/special/dsqrt
PR-URL: #11668 Ref: #8643 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 2cd5062 commit 4948ecc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ float rand_uniformf( float a, float b ) {
114114
*/
115115
static double benchmark( int iterations, int len ) {
116116
double elapsed;
117-
double x[ len ];
118-
double y[ len ];
117+
double *x;
118+
double *y;
119119
double t;
120120
int i;
121121

122+
x = (double *) malloc( len * sizeof( double ) );
123+
y = (double *) malloc( len * sizeof( double ) );
122124
for ( i = 0; i < len; i++ ) {
123125
x[ i ] = rand_uniform( 0.0, 200.0 );
124126
y[ i ] = 0.0;
@@ -136,6 +138,8 @@ static double benchmark( int iterations, int len ) {
136138
if ( y[ 0 ] != y[ 0 ] ) {
137139
printf( "should not return NaN\n" );
138140
}
141+
free( x );
142+
free( y );
139143
return elapsed;
140144
}
141145

0 commit comments

Comments
 (0)