Skip to content

Commit bcf97de

Browse files
committed
bench: refactor to use dynamic memory allocation at number/uint8/base/add
--- 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 53ce62b commit bcf97de

File tree

1 file changed

+3
-1
lines changed
  • lib/node_modules/@stdlib/number/uint8/base/add/benchmark/c

1 file changed

+3
-1
lines changed

lib/node_modules/@stdlib/number/uint8/base/add/benchmark/c/benchmark.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,13 @@ static uint8_t add( const uint8_t x, const uint8_t y ) {
9999
* @return elapsed time in seconds
100100
*/
101101
static double benchmark( void ) {
102-
uint8_t x[ 100 ];
102+
uint8_t *x;
103103
double elapsed;
104104
uint8_t y;
105105
double t;
106106
int i;
107107

108+
x = (uint8_t *) malloc( 100 * sizeof( uint8_t ) );
108109
for ( i = 0; i < 100; i++ ) {
109110
x[ i ] = (uint8_t)( 50.0*rand_double() );
110111
}
@@ -121,6 +122,7 @@ static double benchmark( void ) {
121122
if ( y > 100 ) {
122123
printf( "unexpected result\n" );
123124
}
125+
free( x );
124126
return elapsed;
125127
}
126128

0 commit comments

Comments
 (0)