Skip to content

bench: refactor random number generation in stats/base/dists/triangular #5211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

G4URAV001
Copy link
Contributor

@G4URAV001 G4URAV001 commented Feb 13, 2025

… in JS benchmarks

Resolves #4989 .

Description

What is the purpose of this pull request?

This pull request:

  • This pull request improves random number generation in JS benchmarks for stats/base/dists/triangular. 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

Does this pull request have any 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.

✅ Build Native Add-on.
✅ Run JavaScript Benchmarks.
✅ Run JavaScript Native Benchmarks.


@stdlib-js/reviewers

… in JS 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
---

---
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
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Feb 13, 2025
@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot
Copy link
Contributor

stdlib-bot commented Feb 13, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/triangular/cdf $\color{green}271/271$
$\color{green}+100.00\%$
$\color{green}34/34$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}271/271$
$\color{green}+100.00\%$
stats/base/dists/triangular/ctor $\color{green}524/524$
$\color{green}+100.00\%$
$\color{green}58/58$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}524/524$
$\color{green}+100.00\%$
stats/base/dists/triangular/entropy $\color{green}206/206$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}206/206$
$\color{green}+100.00\%$
stats/base/dists/triangular/kurtosis $\color{green}205/205$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}205/205$
$\color{green}+100.00\%$
stats/base/dists/triangular/logcdf $\color{green}356/356$
$\color{green}+100.00\%$
$\color{green}36/36$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}356/356$
$\color{green}+100.00\%$
stats/base/dists/triangular/logpdf $\color{green}362/362$
$\color{green}+100.00\%$
$\color{green}39/39$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}362/362$
$\color{green}+100.00\%$
stats/base/dists/triangular/mean $\color{green}189/189$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}189/189$
$\color{green}+100.00\%$
stats/base/dists/triangular/median $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}12/12$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$
stats/base/dists/triangular/mgf $\color{green}380/380$
$\color{green}+100.00\%$
$\color{green}38/38$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}380/380$
$\color{green}+100.00\%$
stats/base/dists/triangular/mode $\color{green}189/189$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}189/189$
$\color{green}+100.00\%$
stats/base/dists/triangular/pdf $\color{green}348/348$
$\color{green}+100.00\%$
$\color{green}39/39$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}348/348$
$\color{green}+100.00\%$
stats/base/dists/triangular/quantile $\color{green}356/356$
$\color{green}+100.00\%$
$\color{green}35/35$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}356/356$
$\color{green}+100.00\%$
stats/base/dists/triangular/skewness $\color{green}210/210$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}210/210$
$\color{green}+100.00\%$
stats/base/dists/triangular/stdev $\color{green}206/206$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}206/206$
$\color{green}+100.00\%$
stats/base/dists/triangular/variance $\color{green}197/197$
$\color{green}+100.00\%$
$\color{green}11/11$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}197/197$
$\color{green}+100.00\%$

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

@G4URAV001
Copy link
Contributor Author

i have added the following which stdlib-bot pointed out
"- [x] Read, understood, and followed the contributing guidelines"

@Neerajpathak07
Copy link
Contributor

i have added the following which stdlib-bot pointed out "- [x] Read, understood, and followed the contributing guidelines"

Hey, Could you pls add a space after the hyphen Ig that's what's causing the error.

@G4URAV001
Copy link
Contributor Author

G4URAV001 commented Feb 13, 2025

i have added the following which stdlib-bot pointed out "- [x] Read, understood, and followed the contributing guidelines"

hey, Could you pls add a space after the hyphen Ig that's what's causing the error.

I think it was for the main PR. i didn't had there initially, i added it now. there

@Neerajpathak07
Copy link
Contributor

Apparently the CI errors is specific to the current PR and not affected by other ones. I suppose the change should be made here.

@G4URAV001
Copy link
Contributor Author

Apparently the CI errors is specific to the current PR and not affected by other ones. I suppose the change should be made h

ya i think i made it now in current PR. It should work now

@G4URAV001
Copy link
Contributor Author

@anandkaranubc Can you review the PR now ?

@anandkaranubc
Copy link
Contributor

@anandkaranubc Can you review the PR now ?

On it!

@anandkaranubc
Copy link
Contributor

@G4URAV001 Can you also update the title to:

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

which is just adding backticks around stats/base/dists/triangular

@G4URAV001 G4URAV001 changed the title bench: refactor random number generation in stats/base/dists/triangular bench: refactor random number generation in stats/base/dists/triangular Feb 19, 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: passed
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
@G4URAV001
Copy link
Contributor Author

@anandkaranubc Did the changes, please review this

@anandkaranubc
Copy link
Contributor

@anandkaranubc Did the changes, please review this

On it!

Copy link
Contributor

@anandkaranubc anandkaranubc left a comment

Choose a reason for hiding this comment

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

One small change. Rest, everything looks good! Thanks!

@anandkaranubc anandkaranubc added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Feb 20, 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: passed
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Feb 21, 2025
@Neerajpathak07
Copy link
Contributor

Not something related to this PR But,
I think we should achieve 100% code coverage for the following packages ctor,median and mgf.
@anandkaranubc @kgryte what do you guys think!!

@kgryte
Copy link
Member

kgryte commented Feb 21, 2025

@Neerajpathak07 Agreed. Feel free to submit separate PRs for addressing any gaps in coverage.

@G4URAV001
Copy link
Contributor Author

@anandkaranubc hey please review it I think I made all the corrections

@Planeshifter Planeshifter added the Potential Duplicate There might be another pull request resolving the same issue. label Mar 15, 2025
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Apr 2, 2025
@G4URAV001
Copy link
Contributor Author

Had some bugs in last commit

@G4URAV001 G4URAV001 closed this Apr 2, 2025
@G4URAV001 G4URAV001 deleted the G4URAV001/issue4989 branch April 2, 2025 16:26
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First PR A pull request resolving a Good First Issue. Needs Changes Pull request which needs changes before being merged. Potential Duplicate There might be another pull request resolving the same issue. 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/triangular
6 participants