Skip to content

Commit aca046a

Browse files
committed
feat: add JS native and modify existing 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: na - 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 8584c49 commit aca046a

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bench( pkg, function benchmark( bm ) {
4545
bm.tic();
4646
for ( i = 0; i < bm.iterations; i++ ) {
4747
// eslint-disable-next-line max-len
48-
z = hyp2f1( a[ i % x.length ], b[ i % x.length ], c[ i % x.length ], x[ i % x.length ] );
48+
z = hyp2f1( a[ i%a.length ], b[ i%b.length ], c[ i%c.length ], x[ i%x.length ] );
4949
if ( isnan( z ) ) {
5050
bm.fail( 'should not return NaN' );
5151
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2022 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var tryRequire = require( '@stdlib/utils/try-require' );
28+
var pkg = require( './../package.json' ).name;
29+
30+
31+
// VARIABLES //
32+
33+
var hyp2f1 = tryRequire( resolve( __dirname, './../lib/native.js' ) );
34+
var opts = {
35+
'skip': ( hyp2f1 instanceof Error )
36+
};
37+
38+
39+
// MAIN //
40+
41+
bench( pkg+'::native', opts, function benchmark( bm ) {
42+
var a;
43+
var b;
44+
var c;
45+
var x;
46+
var z;
47+
var i;
48+
49+
a = uniform( 100, -50.0, 50.0 );
50+
b = uniform( 100, -50.0, 50.0 );
51+
c = uniform( 100, -50.0, 50.0 );
52+
x = uniform( 100, -50.0, 50.0 );
53+
54+
bm.tic();
55+
for ( i = 0; i < bm.iterations; i++ ) {
56+
// eslint-disable-next-line max-len
57+
z = hyp2f1( a[ i%a.length ], b[ i%b.length ], c[ i%c.length ], x[ i%x.length ] );
58+
if ( isnan( z ) ) {
59+
bm.fail( 'should not return NaN' );
60+
}
61+
}
62+
bm.toc();
63+
if ( isnan( z ) ) {
64+
bm.fail( 'should not return NaN' );
65+
}
66+
bm.pass( 'benchmark finished' );
67+
bm.end();
68+
});

0 commit comments

Comments
 (0)