Skip to content

Commit cb25fd3

Browse files
Omar-2718kgryte
andauthored
bench: refactor to use dynamic memory allocation in strided/base/smskmap
PR-URL: #9351 Ref: #8643 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 9704456 commit cb25fd3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,16 @@ static float identity( const float x ) {
106106
* @return elapsed time in seconds
107107
*/
108108
static double benchmark( int iterations, int len ) {
109-
uint8_t m[ len ];
110109
double elapsed;
111-
float x[ len ];
112-
float y[ len ];
110+
uint8_t *m;
111+
float *x;
112+
float *y;
113113
double t;
114114
int i;
115115

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

0 commit comments

Comments
 (0)