Skip to content

Commit 913bc0f

Browse files
Updated benchmark.js after review
Signed-off-by: Harsh Mathur <[email protected]>
1 parent cf7a56a commit 913bc0f

File tree

1 file changed

+54
-0
lines changed
  • lib/node_modules/@stdlib/math/base/special/lcmf/benchmark

1 file changed

+54
-0
lines changed

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,60 @@ bench( pkg, function benchmark( b ) {
3434
var y;
3535
var z;
3636
var i;
37+
/**
38+
* @license Apache-2.0
39+
*
40+
* Copyright (c) 2024 The Stdlib Authors.
41+
*
42+
* Licensed under the Apache License, Version 2.0 (the "License");
43+
* you may not use this file except in compliance with the License.
44+
* You may obtain a copy of the License at
45+
*
46+
* http://www.apache.org/licenses/LICENSE-2.0
47+
*
48+
* Unless required by applicable law or agreed to in writing, software
49+
* distributed under the License is distributed on an "AS IS" BASIS,
50+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51+
* See the License for the specific language governing permissions and
52+
* limitations under the License.
53+
*/
54+
55+
'use strict';
56+
57+
// MODULES //
58+
59+
var bench = require( '@stdlib/bench' );
60+
var randu = require( '@stdlib/random/array/discrete-uniform' );
61+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
62+
var pkg = require( './../package.json' ).name;
63+
var lcmf = require( './../lib' );
64+
65+
66+
// MAIN //
67+
68+
bench( pkg, function benchmark( b ) {
69+
var x;
70+
var y;
71+
var z;
72+
var i;
73+
74+
x = randu( 100, 0, 50 );
75+
y = randu( 100, 0, 50 );
76+
77+
b.tic();
78+
for ( i = 0; i < b.iterations; i++ ) {
79+
z = lcmf( x[ i % x.length ], y[ i % y.length ] );
80+
if ( isnanf( z ) ) {
81+
b.fail( 'should not return NaN' );
82+
}
83+
}
84+
b.toc();
85+
if ( isnanf( z ) ) {
86+
b.fail( 'should not return NaN' );
87+
}
88+
b.pass( 'benchmark finished' );
89+
b.end();
90+
});
3791

3892
x = randu( 100, 0, 50 );
3993
y = randu( 100, 0, 50 );

0 commit comments

Comments
 (0)