-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
benchmark: split timers benchmark and refactor #9497
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
The depth benchmark for timers sets a timer that sets a timer that sets a timer that... 500K of them. Since each timer has to wait for the next tick of the event loop this benchmark takes a very long time to run compared to the breadth test that is already in the file. This may be more of an event loop benchmark than a timer benchmark. Reduce the number of iterations for the depth test as it's really just running the iterations in sequence, not in parallel. And even on an infinitely fast machine, it would take over 8 minutes to run because each tick of the event loop would have to wait 1ms before firing the timer. Split the depth and breadth benchmarks so that their `N` values can be set independently. Do some minor refactoring to the benchmarks (but no ES6 additions so that the benchmarks can still be run with old versions of Node.js). Refs: #9493
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 'use strict'; | ||
| var common = require('../common.js'); | ||
|
|
||
| var bench = common.createBenchmark(main, { | ||
| thousands: [500], | ||
| type: ['breadth'] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the filename is included in the output, so this is not needed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed it! Thanks! |
||
| }); | ||
|
|
||
| function main(conf) { | ||
| var N = +conf.thousands * 1e3; | ||
| var n = 0; | ||
| bench.start(); | ||
| function cb() { | ||
| n++; | ||
| if (n === N) | ||
| bench.end(N / 1e3); | ||
| } | ||
| for (var i = 0; i < N; i++) { | ||
| setTimeout(cb, 1); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| 'use strict'; | ||
| var common = require('../common.js'); | ||
|
|
||
| var bench = common.createBenchmark(main, { | ||
| thousands: [1], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
| type: ['depth'] | ||
| }); | ||
|
|
||
| function main(conf) { | ||
| var N = +conf.thousands * 1e3; | ||
| var n = 0; | ||
| bench.start(); | ||
| setTimeout(cb, 1); | ||
| function cb() { | ||
| n++; | ||
| if (n === N) | ||
| bench.end(N / 1e3); | ||
| else | ||
| setTimeout(cb, 1); | ||
| } | ||
| } | ||
This file was deleted.
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.
Nit: trailing comma.