-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[RFC]: Refactor random number generation in JS benchmarks for stats/base/dists/laplace #4976
Copy link
Copy link
Closed
Labels
BenchmarksPull requests adding or improving benchmarks for measuring performance.Pull requests adding or improving benchmarks for measuring performance.Good First IssueA good first issue for new contributors!A good first issue for new contributors!JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.difficulty: 1Low degree of difficulty. Should be straightforward to implement and/or resolve.Low degree of difficulty. Should be straightforward to implement and/or resolve.
Metadata
Metadata
Assignees
Labels
BenchmarksPull requests adding or improving benchmarks for measuring performance.Pull requests adding or improving benchmarks for measuring performance.Good First IssueA good first issue for new contributors!A good first issue for new contributors!JavaScriptIssue involves or relates to JavaScript.Issue involves or relates to JavaScript.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.difficulty: 1Low degree of difficulty. Should be straightforward to implement and/or resolve.Low degree of difficulty. Should be straightforward to implement and/or resolve.
Description
This RFC proposes improving random number generation in JS benchmarks for
stats/base/dists/laplace.Context: At present, in the remaining packages, random number generation in JS benchmarks occurs inside the benchmarking loop. Since random number generation is an expensive operation, it should be moved out of the benchmarking loops and initialized beforehand to avoid interfering with the results.
When adding support, the following tasks should be completed:
Move random number generation out of the benchmarking loops and initialize it before the benchmarks.
Ensure that the generated random values use the same range as the existing values to maintain consistency.
Use
uniformanddiscreteUniformfrom@stdlib/random/base/uniformand@stdlib/random/base/discrete-uniforminstead ofranduexpressions.( randu() * 10.0 + EPS )withuniform( EPS, 10.0 ).ceil( randu() * 10.0 + EPS )withdiscreteUniform( 1, 10 ).To provide a concrete example of what a PR implementing the desired changes should contain, see #4837 and #4955, which provide examples for using both
uniformanddiscreteUniform.Related Issues
#4837, #4955
Questions
No.
Other
Once the implementation is complete, you should be able to run the following
makecommands:Build Native Add-on
NODE_ADDONS_PATTERN="@stdlib/stats/base/dists/laplace/*" make install-node-addonsRun JavaScript Benchmarks
make benchmark-javascript-files FILES="$(pwd)/lib/node_modules/@stdlib/stats/base/dists/laplace/*/benchmark/benchmark.js"Run JavaScript Native Benchmarks
make benchmark-javascript-files FILES="$(pwd)/lib/node_modules/@stdlib/stats/base/dists/laplace/*/benchmark/benchmark.native.js"Note: If running benchmarks results in an error, it is likely due to the random number generators producing values where the functions are not defined. To resolve this, check the relevant benchmark files, adjust the input value ranges to ensure they remain within the domain where the functions are valid, and then rerun the benchmarks. Reference: #4955
Checklist
RFC:.