Skip to content

Commit 11869bb

Browse files
committed
refactor: benchmarks and test messages
--- 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: passed - 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: missing_dependencies - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 8514fc9 commit 11869bb

File tree

8 files changed

+39
-74
lines changed

8 files changed

+39
-74
lines changed

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/benchmark.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pkg = require( './../package.json' ).name;
2727
var acosh = require( './../lib' );
@@ -41,10 +41,11 @@ bench( pkg, function benchmark( b ) {
4141
var y;
4242
var i;
4343

44+
x = uniform( 100, 1.0, 100.0 );
45+
4446
b.tic();
4547
for ( i = 0; i < b.iterations; i++ ) {
46-
x = ( randu()*100.0 ) + 1.0;
47-
y = acosh( x );
48+
y = acosh( x[ i % x.length ] );
4849
if ( isnan( y ) ) {
4950
b.fail( 'should not return NaN' );
5051
}
@@ -62,10 +63,11 @@ bench( pkg+'::built-in', opts, function benchmark( b ) {
6263
var y;
6364
var i;
6465

66+
x = uniform( 100, 1.0, 100.0 );
67+
6568
b.tic();
6669
for ( i = 0; i < b.iterations; i++ ) {
67-
x = ( randu()*100.0 ) + 1.0;
68-
y = Math.acosh( x ); // eslint-disable-line stdlib/no-builtin-math
70+
y = Math.acosh( x[ i % x.length ] ); // eslint-disable-line stdlib/no-builtin-math
6971
if ( isnan( y ) ) {
7072
b.fail( 'should not return NaN' );
7173
}

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/benchmark.native.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4343
var y;
4444
var i;
4545

46+
x = uniform( 100, 1.0, 100.0 );
47+
4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
x = ( randu()*100.0 ) + 1.0;
49-
y = acosh( x );
50+
y = acosh( x[ i % x.length ] );
5051
if ( isnan( y ) ) {
5152
b.fail( 'should not return NaN' );
5253
}

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/c/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,19 @@ static double rand_double( void ) {
8989
* @return elapsed time in seconds
9090
*/
9191
static double benchmark( void ) {
92+
double x[ 100 ];
9293
double elapsed;
93-
double x;
9494
double y;
9595
double t;
9696
int i;
9797

98+
for ( i = 0; i < 100; i++ ) {
99+
x[ i ] = ( 100.0*rand_double() ) + 1.0;
100+
}
101+
98102
t = tic();
99103
for ( i = 0; i < ITERATIONS; i++ ) {
100-
x = ( 100.0*rand_double() ) + 1.0;
101-
y = acosh( x );
104+
y = acosh( x[ i % 100 ] );
102105
if ( y != y ) {
103106
printf( "should not return NaN\n" );
104107
break;

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/c/cephes/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,19 @@ static double rand_double( void ) {
9494
* @return elapsed time in seconds
9595
*/
9696
static double benchmark( void ) {
97+
double x[ 100 ];
9798
double elapsed;
98-
double x;
9999
double y;
100100
double t;
101101
int i;
102102

103+
for ( i = 0; i < 100; i++ ) {
104+
x[ i ] = ( 100.0*rand_double() ) + 1.0;
105+
}
106+
103107
t = tic();
104108
for ( i = 0; i < ITERATIONS; i++ ) {
105-
x = ( 100.0*rand_double() ) + 1.0;
106-
y = acosh( x );
109+
y = acosh( x[ i % 100 ] );
107110
if ( y != y ) {
108111
printf( "should not return NaN\n" );
109112
break;

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/c/native/benchmark.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,19 @@ static double rand_double( void ) {
9090
* @return elapsed time in seconds
9191
*/
9292
static double benchmark( void ) {
93+
double x[ 100 ];
9394
double elapsed;
94-
double x;
9595
double y;
9696
double t;
9797
int i;
9898

99+
for ( i = 0; i < 100; i++ ) {
100+
x[ i ] = ( 100.0*rand_double() ) + 1.0;
101+
}
102+
99103
t = tic();
100104
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 100.0*rand_double() ) + 1.0;
102-
y = stdlib_base_acosh( x );
105+
y = stdlib_base_acosh( x[ i % 100 ] );
103106
if ( y != y ) {
104107
printf( "should not return NaN\n" );
105108
break;

lib/node_modules/@stdlib/math/base/special/acosh/benchmark/cpp/boost/benchmark.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ double tic() {
8585
* @return elapsed time in seconds
8686
*/
8787
double benchmark() {
88+
double x[ 100 ];
8889
double elapsed;
89-
double x;
9090
double y;
9191
double t;
9292
int i;
@@ -97,10 +97,13 @@ double benchmark() {
9797
// Define a uniform distribution for generating pseudorandom numbers as "doubles" between a minimum value (inclusive) and a maximum value (exclusive):
9898
uniform_real_distribution<> randu( 1.0, 101.0 );
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
x[ i ] = randu( rng );
102+
}
103+
100104
t = tic();
101105
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = randu( rng );
103-
y = boost::math::acosh( x );
106+
y = boost::math::acosh( x[ i % 100 ] );
104107
if ( y != y ) {
105108
printf( "should not return NaN\n" );
106109
break;

lib/node_modules/@stdlib/math/base/special/acosh/test/test.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var tape = require( 'tape' );
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var randu = require( '@stdlib/random/base/randu' );
2626
var EPS = require( '@stdlib/constants/float64/eps' );
27-
var abs = require( '@stdlib/math/base/special/abs' );
2827
var acosh = require( './../lib' );
2928

3029

@@ -46,8 +45,6 @@ tape( 'main export is a function', function test( t ) {
4645

4746
tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]', function test( t ) {
4847
var expected;
49-
var delta;
50-
var tol;
5148
var x;
5249
var y;
5350
var i;
@@ -59,19 +56,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]'
5956
y = acosh( x[i] );
6057
if ( y === expected[ i ] ) {
6158
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
62-
} else {
63-
delta = abs( y - expected[i] );
64-
tol = 1.0 * EPS * abs( expected[i] );
65-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
6659
}
6760
}
6861
t.end();
6962
});
7063

7164
tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]', function test( t ) {
7265
var expected;
73-
var delta;
74-
var tol;
7566
var x;
7667
var y;
7768
var i;
@@ -83,19 +74,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]
8374
y = acosh( x[i] );
8475
if ( y === expected[ i ] ) {
8576
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
86-
} else {
87-
delta = abs( y - expected[i] );
88-
tol = 1.0 * EPS * abs( expected[i] );
89-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
9077
}
9178
}
9279
t.end();
9380
});
9481

9582
tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.0]', function test( t ) {
9683
var expected;
97-
var delta;
98-
var tol;
9984
var x;
10085
var y;
10186
var i;
@@ -107,19 +92,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.
10792
y = acosh( x[i] );
10893
if ( y === expected[ i ] ) {
10994
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
110-
} else {
111-
delta = abs( y - expected[i] );
112-
tol = 1.0 * EPS * abs( expected[i] );
113-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
11495
}
11596
}
11697
t.end();
11798
});
11899

119100
tape( 'the function computes the hyperbolic arccosine for huge values', function test( t ) {
120101
var expected;
121-
var delta;
122-
var tol;
123102
var x;
124103
var y;
125104
var i;
@@ -131,18 +110,14 @@ tape( 'the function computes the hyperbolic arccosine for huge values', function
131110
y = acosh( x[i] );
132111
if ( y === expected[ i ] ) {
133112
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
134-
} else {
135-
delta = abs( y - expected[i] );
136-
tol = 1.0 * EPS * abs( expected[i] );
137-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
138113
}
139114
}
140115
t.end();
141116
});
142117

143118
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
144119
var v = acosh( NaN );
145-
t.equal( isnan( v ), true, 'returns NaN' );
120+
t.equal( isnan( v ), true, 'returns expected value' );
146121
t.end();
147122
});
148123

@@ -152,7 +127,7 @@ tape( 'the function returns `NaN` if provided value less than `1`', function tes
152127

153128
for ( i = 0; i < 1e3; i++ ) {
154129
v = -(randu()*1.0e6) + (1-EPS);
155-
t.equal( isnan( acosh( v ) ), true, 'returns NaN when provided '+v );
130+
t.equal( isnan( acosh( v ) ), true, 'returns expected value when provided '+v );
156131
}
157132
t.end();
158133
});

lib/node_modules/@stdlib/math/base/special/acosh/test/test.native.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var tape = require( 'tape' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var randu = require( '@stdlib/random/base/randu' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
28-
var abs = require( '@stdlib/math/base/special/abs' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
3029

3130

@@ -55,8 +54,6 @@ tape( 'main export is a function', opts, function test( t ) {
5554

5655
tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]', opts, function test( t ) {
5756
var expected;
58-
var delta;
59-
var tol;
6057
var x;
6158
var y;
6259
var i;
@@ -68,19 +65,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [1.0,3.0]'
6865
y = acosh( x[i] );
6966
if ( y === expected[ i ] ) {
7067
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
71-
} else {
72-
delta = abs( y - expected[i] );
73-
tol = 1.0 * EPS * abs( expected[i] );
74-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
7568
}
7669
}
7770
t.end();
7871
});
7972

8073
tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]', opts, function test( t ) {
8174
var expected;
82-
var delta;
83-
var tol;
8475
var x;
8576
var y;
8677
var i;
@@ -92,19 +83,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [3.0,28.0]
9283
y = acosh( x[i] );
9384
if ( y === expected[ i ] ) {
9485
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
95-
} else {
96-
delta = abs( y - expected[i] );
97-
tol = 1.0 * EPS * abs( expected[i] );
98-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
9986
}
10087
}
10188
t.end();
10289
});
10390

10491
tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.0]', opts, function test( t ) {
10592
var expected;
106-
var delta;
107-
var tol;
10893
var x;
10994
var y;
11095
var i;
@@ -116,19 +101,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval [28.0,100.
116101
y = acosh( x[i] );
117102
if ( y === expected[ i ] ) {
118103
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
119-
} else {
120-
delta = abs( y - expected[i] );
121-
tol = 1.0 * EPS * abs( expected[i] );
122-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
123104
}
124105
}
125106
t.end();
126107
});
127108

128109
tape( 'the function computes the hyperbolic arccosine for huge values', opts, function test( t ) {
129110
var expected;
130-
var delta;
131-
var tol;
132111
var x;
133112
var y;
134113
var i;
@@ -140,18 +119,14 @@ tape( 'the function computes the hyperbolic arccosine for huge values', opts, fu
140119
y = acosh( x[i] );
141120
if ( y === expected[ i ] ) {
142121
t.equal( y, expected[ i ], 'x: '+x[i]+'. E: '+expected[i] );
143-
} else {
144-
delta = abs( y - expected[i] );
145-
tol = 1.0 * EPS * abs( expected[i] );
146-
t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
147122
}
148123
}
149124
t.end();
150125
});
151126

152127
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
153128
var v = acosh( NaN );
154-
t.equal( isnan( v ), true, 'returns NaN' );
129+
t.equal( isnan( v ), true, 'returns expected value' );
155130
t.end();
156131
});
157132

@@ -161,7 +136,7 @@ tape( 'the function returns `NaN` if provided value less than `1`', opts, functi
161136

162137
for ( i = 0; i < 1e3; i++ ) {
163138
v = -(randu()*1.0e6) + (1-EPS);
164-
t.equal( isnan( acosh( v ) ), true, 'returns NaN when provided '+v );
139+
t.equal( isnan( acosh( v ) ), true, 'returns expected value when provided '+v );
165140
}
166141
t.end();
167142
});

0 commit comments

Comments
 (0)