Skip to content

Conversation

G4URAV001
Copy link
Contributor

@G4URAV001 G4URAV001 commented Feb 10, 2025

…ts/uniform

#4991

Resolves #4991 .

Description

What is the purpose of this pull request?

This pull request improves random number generation in JS benchmarks for stats/base/dists/uniform. Specifically:

  • Moves random number generation out of benchmarking loops to prevent interference with benchmark results.
  • Uses @stdlib/random/base/uniform and @stdlib/random/base/discrete-uniform instead of randu expressions.
  • Ensures generated random values maintain the same range as existing values for consistency.

Related Issues

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

✅ Read, understood, and followed the contributing guidelines.
✅ Build Native Add-on.
✅ Run JavaScript Benchmarks.
✅ Run JavaScript Native Benchmarks.


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Feb 10, 2025
Copy link
Contributor

@stdlib-bot stdlib-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Feb 10, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/uniform/cdf $\color{green}225/225$
$\color{green}+100.00\%$
$\color{green}25/25$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}225/225$
$\color{green}+100.00\%$
stats/base/dists/uniform/ctor $\color{green}479/479$
$\color{green}+100.00\%$
$\color{green}43/43$
$\color{green}+100.00\%$
$\color{green}18/18$
$\color{green}+100.00\%$
$\color{green}479/479$
$\color{green}+100.00\%$
stats/base/dists/uniform/entropy $\color{green}184/184$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}184/184$
$\color{green}+100.00\%$
stats/base/dists/uniform/kurtosis $\color{green}186/186$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}186/186$
$\color{green}+100.00\%$
stats/base/dists/uniform/logcdf $\color{green}229/229$
$\color{green}+100.00\%$
$\color{green}25/25$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}229/229$
$\color{green}+100.00\%$
stats/base/dists/uniform/logpdf $\color{green}219/219$
$\color{green}+100.00\%$
$\color{green}23/23$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}219/219$
$\color{green}+100.00\%$
stats/base/dists/uniform/mean $\color{green}175/175$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}175/175$
$\color{green}+100.00\%$
stats/base/dists/uniform/median $\color{green}175/175$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}175/175$
$\color{green}+100.00\%$
stats/base/dists/uniform/mgf $\color{green}235/235$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}235/235$
$\color{green}+100.00\%$
stats/base/dists/uniform/pdf $\color{green}287/287$
$\color{green}+100.00\%$
$\color{green}25/25$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}287/287$
$\color{green}+100.00\%$
stats/base/dists/uniform/quantile $\color{green}215/215$
$\color{green}+100.00\%$
$\color{green}22/22$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}215/215$
$\color{green}+100.00\%$
stats/base/dists/uniform/skewness $\color{green}119/119$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}119/119$
$\color{green}+100.00\%$
stats/base/dists/uniform/stdev $\color{green}122/122$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}122/122$
$\color{green}+100.00\%$
stats/base/dists/uniform/variance $\color{green}182/182$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}182/182$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

@G4URAV001 G4URAV001 changed the title Refactor random number generation in JS benchmarks for stats/base/dists/uniform #4991 bench: Refactor random number generation in JS benchmarks for stats/base/dists/uniform #4991 Feb 10, 2025
@anandkaranubc anandkaranubc added the Needs Changes Pull request which needs changes before being merged. label Feb 10, 2025
@anandkaranubc
Copy link
Contributor

Thanks @G4URAV001 for working on this. Left a few comments for you to review. Good luck!

@G4URAV001
Copy link
Contributor Author

Thanks @G4URAV001 for working on this. Left a few comments for you to review. Good luck!

Thanks @anandkaranubc for the comments. Did all the correction and ran the following tests locally in a dev container -

[x] Build Native Add-on.
[x] Run JavaScript Benchmarks.
[x] Run JavaScript Native Benchmarks.

Still if anything is missed I can do the changes

Sorry for the silly things I missed earlier, I should have been more observant.

Looking forward for more contributions

@Planeshifter
Copy link
Member

/stdlib lint-autofix

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Feb 11, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Feb 11, 2025
Signed-off-by: Philipp Burckhardt <[email protected]>
@Planeshifter
Copy link
Member

/stdlib lint-autofix

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Feb 11, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Feb 11, 2025
---
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
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
---
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
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first PR, which I will go ahead and merge shortly.

Going forward, please make sure you have your local development environment setup correctly, including EditorConfig and ESLint. The PR had a bunch of lint errors that would have been caught by our GIt hooks if properly initialized.

@Planeshifter Planeshifter changed the title bench: Refactor random number generation in JS benchmarks for stats/base/dists/uniform #4991 bench: refactor random number generation in JS benchmarks for stats/base/dists/uniform Feb 12, 2025
@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Feb 12, 2025
@stdlib-bot stdlib-bot removed Needs Review A pull request which needs code review. Needs Changes Pull request which needs changes before being merged. labels Feb 12, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Feb 12, 2025

PR Commit Message

bench: refactor random number generation in JS benchmarks for `stats/base/dists/uniform`

PR-URL: https://github.com/stdlib-js/stdlib/pull/5176
Closes: https://github.com/stdlib-js/stdlib/issues/4991
Ref: https://github.com/stdlib-js/stdlib/issues/4837
Ref: https://github.com/stdlib-js/stdlib/issues/4955

Co-authored-by: Philipp Burckhardt <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
Reviewed-by: Karan Anand <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter merged commit 273d9f1 into stdlib-js:develop Feb 12, 2025
27 of 28 checks passed
@G4URAV001 G4URAV001 deleted the G4URAV001/Issue4991 branch February 12, 2025 02:05
ShabiShett07 pushed a commit to ShabiShett07/stdlib that referenced this pull request Feb 26, 2025
…e/dists/uniform`

PR-URL: stdlib-js#5176
Closes: stdlib-js#4991
Ref: stdlib-js#4837
Ref: stdlib-js#4955

Co-authored-by: Philipp Burckhardt <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
Reviewed-by: Karan Anand <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Ready To Merge A pull request which is ready to be merged. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Refactor random number generation in JS benchmarks for stats/base/dists/uniform
4 participants