Skip to content

Commit 7abf629

Browse files
committed
bench: refactor to use dynamic memory allocation in strided/base/zmap
--- 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: passed - 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 ---
1 parent a0ef914 commit 7abf629

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ static double complex identity( const double complex x ) {
106106
* @return elapsed time in seconds
107107
*/
108108
static double benchmark( int iterations, int len ) {
109-
double complex x[ len ];
110-
double complex y[ len ];
109+
double complex *x;
110+
double complex *y;
111111
double elapsed;
112112
double t;
113113
int i;
114114

115+
x = (double complex *)malloc( len * sizeof( double complex ) );
116+
y = (double complex *)malloc( len * sizeof( double complex ) );
115117
for ( i = 0; i < len; i++ ) {
116118
x[ i ] = ( ( rand_double()*200.0 ) - 100.0 ) + ( ( rand_double()*200.0 ) - 100.0 )*I;
117119
y[ i ] = 0.0 + 0.0*I;
@@ -129,6 +131,8 @@ static double benchmark( int iterations, int len ) {
129131
if ( y[ i%len ] != y[ i%len ] ) {
130132
printf( "should not return NaN\n" );
131133
}
134+
free( x );
135+
free( y );
132136
return elapsed;
133137
}
134138

0 commit comments

Comments
 (0)