Skip to content

Commit 20c6e2f

Browse files
committed
bench: update benchmarks
--- 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: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 618b2a6 commit 20c6e2f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bench( pkg, function benchmark( b ) {
4040

4141
b.tic();
4242
for ( i = 0; i < b.iterations; i++ ) {
43-
y = kernelLog1pf( x[ i % x.length ] );
43+
y = kernelLog1pf( x[ i%x.length ] );
4444
if ( isnanf( y ) ) {
4545
b.fail( 'should not return NaN' );
4646
}

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4949

5050
b.tic();
5151
for ( i = 0; i < b.iterations; i++ ) {
52-
y = kernelLog1pf( x[ i % x.length ] );
52+
y = kernelLog1pf( x[ i%x.length ] );
5353
if ( isnanf( y ) ) {
5454
b.fail( 'should not return NaN' );
5555
}

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/c/native/benchmark.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static double rand_float( void ) {
83-
int r = rand();
84-
return (float)r / ( (float)RAND_MAX + 1.0f );
84+
static float random_uniform( const float min, const float max ) {
85+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -97,12 +99,12 @@ static double benchmark( void ) {
9799
int i;
98100

99101
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( rand_float() + 1.0f ) * 0.70710677f;
102+
x[ i ] = random_uniform( 0.7071067690849304f, 1.4142135381698608f ); // ~[sqrt(2)/2, sqrt(2)]
101103
}
102104

103105
t = tic();
104106
for ( i = 0; i < ITERATIONS; i++ ) {
105-
z = stdlib_base_kernel_log1pf( x[ i % 100 ] );
107+
z = stdlib_base_kernel_log1pf( x[ i%100 ] );
106108
if ( z != z ) {
107109
printf( "should not return NaN\n" );
108110
break;
@@ -127,7 +129,7 @@ int main( void ) {
127129

128130
print_version();
129131
for ( i = 0; i < REPEATS; i++ ) {
130-
printf( "# c::native%s\n", NAME );
132+
printf( "# c::native::%s\n", NAME );
131133
elapsed = benchmark();
132134
print_results( elapsed );
133135
printf( "ok %d benchmark finished\n", i+1 );

0 commit comments

Comments
 (0)