From 44685bd92ade53b9c6a8fa85c95835e9a8d3398c Mon Sep 17 00:00:00 2001 From: Samarth Kolarkar Date: Thu, 18 Dec 2025 19:07:12 +0530 Subject: [PATCH] bench: refactor to use dynamic memory allocation in blas/base/ssyr --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/base/ssyr/benchmark/c/benchmark.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c/benchmark.c index 08a08b53a12f..f4e4ec1cd62f 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/blas/base/ssyr/benchmark/c/benchmark.c @@ -88,11 +88,13 @@ static double tic( void ) { */ static double benchmark1( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; + float *A; + float *x; double t; int i; + x = (float *)malloc( N * sizeof( float ) ); + A = (float *)malloc( N * N * sizeof( float ) ); stdlib_strided_sfill( N, 1.0f, x, 1 ); stdlib_strided_sfill( N*N, 1.0f, A, 1 ); t = tic(); @@ -107,6 +109,8 @@ static double benchmark1( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( A ); return elapsed; } @@ -119,11 +123,13 @@ static double benchmark1( int iterations, int N ) { */ static double benchmark2( int iterations, int N ) { double elapsed; - float A[ N*N ]; - float x[ N ]; + float *A; + float *x; double t; int i; + x = (float *)malloc( N * sizeof( float ) ); + A = (float *)malloc( N * N * sizeof( float ) ); stdlib_strided_sfill( N, 1.0f, x, 1 ); stdlib_strided_sfill( N*N, 1.0f, A, 1 ); t = tic(); @@ -138,6 +144,8 @@ static double benchmark2( int iterations, int N ) { if ( A[ i%(N*2) ] != A[ i%(N*2) ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( A ); return elapsed; }