Skip to content

Commit 1347256

Browse files
committed
bench: refactor to use dynamic memory allocation in stats/strided/dmskmin
--- 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 ---
1 parent fd99196 commit 1347256

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/node_modules/@stdlib/stats/strided/dmskmin/benchmark/c/benchmark.length.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ static double rand_double( void ) {
9797
static double benchmark1( int iterations, int len ) {
9898
unsigned char mask[ len ];
9999
double elapsed;
100-
double x[ len ];
100+
double *x;
101101
double v;
102102
double t;
103103
int i;
104104

105+
x = (double *) malloc( len * sizeof( double ) );
105106
for ( i = 0; i < len; i++ ) {
106107
if ( rand_double() < 0.2 ) {
107108
mask[ i ] = 1; // missing
@@ -124,6 +125,7 @@ static double benchmark1( int iterations, int len ) {
124125
if ( v != v ) {
125126
printf( "should not return NaN\n" );
126127
}
128+
free( x );
127129
return elapsed;
128130
}
129131

@@ -137,11 +139,12 @@ static double benchmark1( int iterations, int len ) {
137139
static double benchmark2( int iterations, int len ) {
138140
unsigned char mask[ len ];
139141
double elapsed;
140-
double x[ len ];
142+
double *x;
141143
double v;
142144
double t;
143145
int i;
144146

147+
x = (double *) malloc( len * sizeof( double ) );
145148
for ( i = 0; i < len; i++ ) {
146149
if ( rand_double() < 0.2 ) {
147150
mask[ i ] = 1; // missing
@@ -164,6 +167,7 @@ static double benchmark2( int iterations, int len ) {
164167
if ( v != v ) {
165168
printf( "should not return NaN\n" );
166169
}
170+
free( x );
167171
return elapsed;
168172
}
169173

0 commit comments

Comments
 (0)