From ad10b3f9ae9b3c53277a5cf0c115dcaca57a0ff7 Mon Sep 17 00:00:00 2001 From: ishwarthecodddr Date: Mon, 8 Dec 2025 15:38:31 +0530 Subject: [PATCH] bench: refactor to use dynamic memory allocation in blas/base/caxpy --- .../base/caxpy/benchmark/c/benchmark.length.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/c/benchmark.length.c index 69d5c9c8d9f2..391006a54011 100644 --- a/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/caxpy/benchmark/c/benchmark.length.c @@ -97,13 +97,15 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { stdlib_complex64_t alpha; - float x[ len*2 ]; - float y[ len*2 ]; + float *x; + float *y; double elapsed; double t; int i; alpha = stdlib_complex64( 1.0f, 0.0f ); + x = (float *) malloc( len * 2 * sizeof( float ) ); + y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; x[ i+1 ] = ( rand_float()*2.0f ) - 1.0f; @@ -122,6 +124,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -134,13 +138,15 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { stdlib_complex64_t alpha; - float x[ len*2 ]; - float y[ len*2 ]; + float *x; + float *y; double elapsed; double t; int i; alpha = stdlib_complex64( 1.0f, 0.0f ); + x = (float *) malloc( len * 2 * sizeof( float ) ); + y = (float *) malloc( len * 2 * sizeof( float ) ); for ( i = 0; i < len*2; i += 2 ) { x[ i ] = ( rand_float()*2.0f ) - 1.0f; x[ i+1 ] = ( rand_float()*2.0f ) - 1.0f; @@ -159,6 +165,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ 0 ] != y[ 0 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; }