-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add raf based measurement #173
Conversation
11ab3c4
to
142589c
Compare
resources/benchmark-runner.mjs
Outdated
let syncTime; | ||
let asyncStartTime; | ||
let asyncTime; | ||
const invokerClass = params.measurementMethod === 'raf' ? RAFTestInvoker : TimerTestInvoker; |
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.
nice!
Modulo function-names / bind comment. Looking good! |
resources/benchmark-runner.mjs
Outdated
let asyncStartTime; | ||
let asyncTime; | ||
const invokerClass = params.measurementMethod === 'raf' ? RAFTestInvoker : TimerTestInvoker; | ||
const invoker = new invokerClass(() => { |
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.
As on the other PR, maybe named-methods + bind makes this more readable?
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.
What do you mean by that? Could you show me an example?
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.
Along these lines (implying moving the *time values onto the class):
const invoker = new invokerClass(this.measureSync.bind(this), this.measureAsync.bind(this), this._report.bind(this));
...
}
measureSync(...) {
...
}
measureAsync(...) {
...
}
...
Maybe easier: using named arrow functions would be an improvement:
...
const syncStart = () => {...};
const measureAsync = () => {...};
const report = () => {...};
const invoker = new invokerClass(measureSync, measureAsync, report);
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.
.bind() makes it harder to read ;)
But that latter case looks better to me.
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.
Done that.
return this._recordTestResults(suite, test, syncTime, asyncTime); | ||
}); | ||
|
||
return invoker.start(); |
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.
Maybe await invoker.start();
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.
r+ for the actual benchmark-runner. (I'm less familiar with test tests/* code).
Perhaps assign the callbacks to variables and pass those as params, that might improve the readability a bit.
142589c
to
74bbaf6
Compare
This PR adds a new query string parameter requestAnimationFrame, which takes the value of either "timer" or "raf". "timer" is the existing and default measurement method. When it's "raf", we use two consecutive requestAnimationFrame first of which runs the sync step and second of which schedules a 0s timer to signify the end of async step.
74bbaf6
to
d2750a4
Compare
This PR adds a new query string parameter requestAnimationFrame, which takes the value of either "timer" or "raf". "timer" is the existing and default measurement method. When it's "raf", we use two consecutive requestAnimationFrame first of which runs the sync step and second of which schedules a 0s timer to signify the end of async step.