Skip to content

Commit ac1e2d1

Browse files
committed
bench: add 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 58996d4 commit ac1e2d1

File tree

1 file changed

+125
-0
lines changed
  • lib/node_modules/@stdlib/lapack/base/dgtts2/benchmark

1 file changed

+125
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var pow = require( '@stdlib/math/base/special/pow' );
28+
var floor = require( '@stdlib/math/base/special/floor' );
29+
var pkg = require( './../package.json' ).name;
30+
var dlaswp = require( './../lib/dgtts2.js' );
31+
32+
33+
// VARIABLES //
34+
35+
var LAYOUTS = [
36+
'row-major',
37+
'column-major'
38+
];
39+
var opts = {
40+
'dtype': 'float64'
41+
};
42+
43+
44+
// FUNCTIONS //
45+
46+
/**
47+
* Creates a benchmark function.
48+
*
49+
* @private
50+
* @param {string} order - storage layout
51+
* @param {PositiveInteger} itrans - specifies the form of the system of equations
52+
* @param {PositiveInteger} N - number of elements along each dimension
53+
* @returns {Function} benchmark function
54+
*/
55+
function createBenchmark( order, itrans, N ) {
56+
var IPIV = discreteUniform( N, 0, N-1, {
57+
'dtype': 'int32'
58+
});
59+
var DU2 = uniform( N-2, 10.0, 100.0, opts );
60+
var DL = uniform( N-1, 10.0, 100.0, opts );
61+
var DU = uniform( N-1, 10.0, 100.0, opts );
62+
var D = uniform( N, 10.0, 100.0, opts );
63+
var B = uniform( N*N, 10.0, 30.0, opts );
64+
return benchmark;
65+
66+
/**
67+
* Benchmark function.
68+
*
69+
* @private
70+
* @param {Benchmark} b - benchmark instance
71+
*/
72+
function benchmark( b ) {
73+
var z;
74+
var i;
75+
76+
b.tic();
77+
for ( i = 0; i < b.iterations; i++ ) {
78+
z = dlaswp( order, itrans, N, DL, D, DU, DU2, IPIV, B, N );
79+
if ( isnan( z[ i%z.length ] ) ) {
80+
b.fail( 'should not return NaN' );
81+
}
82+
}
83+
b.toc();
84+
if ( isnan( z[ i%z.length ] ) ) {
85+
b.fail( 'should not return NaN' );
86+
}
87+
b.pass( 'benchmark finished' );
88+
b.end();
89+
}
90+
}
91+
92+
93+
// MAIN //
94+
95+
/**
96+
* Main execution sequence.
97+
*
98+
* @private
99+
*/
100+
function main() {
101+
var itrans;
102+
var min;
103+
var max;
104+
var ord;
105+
var N;
106+
var f;
107+
var i;
108+
var k;
109+
110+
min = 1; // 10^min
111+
max = 6; // 10^max
112+
113+
for ( k = 0; k < LAYOUTS.length; k++ ) {
114+
ord = LAYOUTS[ k ];
115+
for ( itrans = 0; itrans < 3; itrans++ ) {
116+
for ( i = min; i <= max; i++ ) {
117+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
118+
f = createBenchmark( ord, itrans, N );
119+
bench( pkg+'::square_matrix:order='+ord+',itrans='+itrans+',size='+(N*N), f );
120+
}
121+
}
122+
}
123+
}
124+
125+
main();

0 commit comments

Comments
 (0)