-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 spread operator benchmark #11227
Conversation
benchmark/es/spread-bench.js
Outdated
|
||
const bench = common.createBenchmark(main, { | ||
method: ['apply', 'spread'], | ||
count: [5, 10, 20], |
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.
We can add a config for context: ['context', 'null']
so we can benchmark against things like fn.apply(context, args)
, fn.call(context, ..args)
and fn2 = fn.bind(context); [...] fn2.call(..args) [...]
too.
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!
0b4fec0
to
d6473e3
Compare
benchmark/es/spread-bench.js
Outdated
}); | ||
|
||
function makeTest(count) { | ||
return function test(...args) { |
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.
Is it intentional to use spread here as well? It might be interesting to test with/without it in case V8 should make optimizations depending on use of spread in either/both places?
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 it's intentional but good suggestion on separating those out.
@nodejs/benchmarking ... PTAL |
I think I saw somewhere mentioned the benchmark team is more about https://benchmarking.nodejs.org/ than changes to our benchmark directory...? |
Yes, but it's always good to get benchmark focused folks looking at things like this :-) |
benchmark/es/spread-bench.js
Outdated
const n = +conf.millions * 1e6; | ||
const ctx = conf.context === 'context' ? {} : null; | ||
var fn = makeTest(conf.count, conf.rest); | ||
const args = Array(conf.count); |
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 think new
should be added here, or just use []
.
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.
Updated!
2d0ea1b
to
86f6d04
Compare
@mscdex PTAL! |
function main(conf) { | ||
const n = +conf.millions * 1e6; | ||
const ctx = conf.context === 'context' ? {} : null; | ||
var fn = makeTest(conf.count, conf.rest); |
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 think the linter may be complaining about this, that it should be const
. Might want to run it locally just to be sure.
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.
O.o .. nope, just a missing ;
... fixed!
Useful for comparing spread operator performance over time.
86f6d04
to
ab4a666
Compare
Lint again: https://ci.nodejs.org/job/node-test-linter/6981/ |
Linter is green. LGTM. |
Useful for comparing spread operator performance over time. PR-URL: #11227 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Brian White <[email protected]>
Landed in 595df9f |
Useful for comparing spread operator performance over time. PR-URL: #11227 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Brian White <[email protected]>
Useful for comparing spread operator performance over time. PR-URL: nodejs#11227 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Brian White <[email protected]>
Useful for comparing spread operator performance over time. PR-URL: nodejs#11227 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Brian White <[email protected]>
Useful for comparing spread operator performance over time.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
benchmarks