-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
feat: refactor random number generation stats/base/dists/weibull
#5011
base: develop
Are you sure you want to change the base?
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Can you please change the title to: bench: refactor random number generation in |
Also, I am not sure if you have the most recent changes in your current branch. Try to update your branch with the latest changes so you can also apply the required changes to all the |
x[ i ] = uniform( EPS, 100 ); | ||
lambda[ i ] = uniform( EPS, 100 ); | ||
k[ i ] = uniform( EPS, 100 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved outside the benchmarking loops in a different loop before b.tic()
Since random generation is expensive, we don't want it to interfere with the benchmarks. You can see the reference PRs. Also, this change is consistent throughout the whole PR.
lambda = ( randu()*100.0 ) + EPS; | ||
k = ( randu()*100.0 ) + EPS; | ||
y = cdf( x, k, lambda ); | ||
for ( i = 0; i < len; i++ ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for ( i = 0; i < len; i++ ) { | |
for ( i = 0; i < b.iterations; i++ ) { |
The range remains the same.
x[ i ] = uniform( EPS, 100 ); | ||
lambda[ i ] = uniform( EPS, 100 ); | ||
k[ i ] = uniform( EPS, 100 ); | ||
y = cdf( x[ i%len ], k[ i%len ], lambda[ i%len ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y = cdf( x[ i%len ], k[ i%len ], lambda[ i%len ] ); | |
y = cdf( x[ i % len ], k[ i % len ], lambda[ i % len ] ); |
k = ( randu()*100.0 ) + EPS; | ||
y = cdf( x, k, lambda ); | ||
for ( i = 0; i < len; i++ ) { | ||
x[ i ] = uniform( EPS, 100 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x[ i ] = uniform( EPS, 100 ); | |
x[ i ] = uniform( EPS, 100.0 ); |
lambda = 3.14; | ||
k = 2.25; | ||
mycdf = cdf.factory( k, lambda ); | ||
len = 100; | ||
|
||
x = new Float64Array( len ); | ||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
x = ( randu()*100.0 ) + EPS; | ||
y = mycdf( x ); | ||
x[ i ] = uniform( EPS, 100.0 ); | ||
y = mycdf( x[ i%len ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lambda = 3.14;
k = 2.25;
len = 100
mycdf = cdf.factory( k, lambda );
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x = uniform( EPS, 100.0 );
}
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = mycdf( x[ i % len ] );
Make sure to follow consistent spacing, following the code conventions.
Resolves #4992
Description
This pull request:
stats/base/dists/weibull
#4992Related Issues
This pull request:
stats/base/dists/weibull
#4992 [RFC]: Refactor random number generation in JS benchmarks forstats/base/dists
(tracking issue) #4993Questions
What about the benchmark of ctor? Do we need to change that too?
Other
No.
Checklist
@stdlib-js/reviewers