Skip to content

Commit d53c05c

Browse files
committed
Auto-generated commit
1 parent 846ffa5 commit d53c05c

4 files changed

Lines changed: 141 additions & 1 deletion

File tree

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22

33
> Package changelog.
44
5+
<section class="release" id="unreleased">
6+
7+
## Unreleased (2026-04-19)
8+
9+
<section class="commits">
10+
11+
### Commits
12+
13+
<details>
14+
15+
- [`4574e32`](https://github.com/stdlib-js/stdlib/commit/4574e3216991a30ec46d3b4a2d5e9d84e31da20e) - **bench:** add factory benchmarks to `random/base` PRNGs [(#11563)](https://github.com/stdlib-js/stdlib/pull/11563) _(by Philipp Burckhardt)_
16+
17+
</details>
18+
19+
</section>
20+
21+
<!-- /.commits -->
22+
23+
<section class="contributors">
24+
25+
### Contributors
26+
27+
A total of 1 person contributed to this release. Thank you to this contributor:
28+
29+
- Philipp Burckhardt
30+
31+
</section>
32+
33+
<!-- /.contributors -->
34+
35+
</section>
36+
37+
<!-- /.release -->
38+
539
<section class="release" id="v0.2.2">
640

741
## 0.2.2 (2026-02-08)

benchmark/benchmark.factory.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 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-harness' );
24+
var Uint32Array = require( '@stdlib/array-uint32' );
25+
var isnan = require( '@stdlib/math-base-assert-is-nan' );
26+
var minstd = require( '@stdlib/random-base-minstd-shuffle' );
27+
var format = require( '@stdlib/string-format' );
28+
var pkg = require( './../package.json' ).name;
29+
var factory = require( './../lib' ).factory;
30+
31+
32+
// MAIN //
33+
34+
bench( format( '%s:factory', pkg ), function benchmark( b ) {
35+
var f;
36+
var i;
37+
38+
b.tic();
39+
for ( i = 0; i < b.iterations; i++ ) {
40+
f = factory();
41+
if ( typeof f !== 'function' ) {
42+
b.fail( 'should return a function' );
43+
}
44+
}
45+
b.toc();
46+
if ( isnan( f() ) ) {
47+
b.fail( 'should not return NaN' );
48+
}
49+
b.pass( 'benchmark finished' );
50+
b.end();
51+
});
52+
53+
bench( format( '%s:factory:seed=<integer>', pkg ), function benchmark( b ) {
54+
var opts;
55+
var f;
56+
var i;
57+
58+
opts = {
59+
'seed': 1
60+
};
61+
62+
b.tic();
63+
for ( i = 0; i < b.iterations; i++ ) {
64+
opts.seed += i;
65+
f = factory( opts );
66+
if ( typeof f !== 'function' ) {
67+
b.fail( 'should return a function' );
68+
}
69+
}
70+
b.toc();
71+
if ( isnan( f() ) ) {
72+
b.fail( 'should not return NaN' );
73+
}
74+
b.pass( 'benchmark finished' );
75+
b.end();
76+
});
77+
78+
bench( format( '%s:factory:seed=<array>', pkg ), function benchmark( b ) {
79+
var seed;
80+
var opts;
81+
var f;
82+
var i;
83+
84+
opts = {};
85+
86+
seed = new Uint32Array( 10 );
87+
for ( i = 0; i < seed.length; i++ ) {
88+
seed[ i ] = minstd();
89+
}
90+
opts.seed = seed;
91+
92+
b.tic();
93+
for ( i = 0; i < b.iterations; i++ ) {
94+
opts.seed[ 0 ] = i + 1;
95+
f = factory( opts );
96+
if ( typeof f !== 'function' ) {
97+
b.fail( 'should return a function' );
98+
}
99+
}
100+
b.toc();
101+
if ( isnan( f() ) ) {
102+
b.fail( 'should not return NaN' );
103+
}
104+
b.pass( 'benchmark finished' );
105+
b.end();
106+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@stdlib/math-base-assert-is-nan": "^0.2.3",
6060
"@stdlib/process-env": "^0.2.3",
6161
"@stdlib/random-base-minstd": "^0.2.3",
62+
"@stdlib/random-base-minstd-shuffle": "^0.2.3",
6263
"@stdlib/stats-kstest": "^0.2.3",
6364
"@stdlib/time-now": "^0.2.3",
6465
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",

0 commit comments

Comments
 (0)