-
Notifications
You must be signed in to change notification settings - Fork 38
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
benchmarks: add Ramanujan's formula for calculating pi #483
Conversation
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.
Looks ok. How long does it run?
test/benchmarks/ramunajan_pi.inputs
Outdated
|
||
31415926535897932 | ||
|
||
pi_30_runs |
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.
I don't think adding more than one execution benchmark adds any additional information. It rather just make running benchmarks take longer.
62f20d0
to
9f97cd7
Compare
Codecov Report
@@ Coverage Diff @@
## master #483 +/- ##
=======================================
Coverage 99.67% 99.67%
=======================================
Files 54 54
Lines 17180 17180
=======================================
Hits 17125 17125
Misses 55 55 |
The wat can be found here: https://gist.github.com/axic/1b330d744148e2aa46085f0f69521b40 |
{ | ||
// This dumb implementation of Ramanujan series calculates 1/pi | ||
double ret = 0.0; | ||
for (unsigned k = 0; k < n; k++) { |
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 "more floating point" and fun, you can make it double k
.
|
||
#define WASM_EXPORT __attribute__((visibility("default"))) | ||
|
||
static unsigned factorial(unsigned n) |
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.
Can be also implemented with double n
.
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.
Yeah thought about those, but kind of resorted that perhaps for forcefully having "more floating point" perhaps a hand crafted synthetic benchmark using all ops is better?
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.
So what's the point of this benchmark if only 10-20% of instructions is floating-point?
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.
Absolute number of instructions or instructions weighted by the number of times they are executed?
If you profile it it should be clear the heavy part is the floating point calculation (pow, etc.). The factorial part only works with small number (<30).
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.
Ok then.
See