-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process: slightly simplify next tick execution
Get rid of separate function to call callback from _tickCallback as it no longer yields worthwhile performance improvement. Move some code from nextTick & internalNextTick into TickObject constructor to minimize duplication. PR-URL: #16888 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
- Loading branch information
1 parent
1f5ee33
commit cbaf59c
Showing
8 changed files
with
81 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [5] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.millions * 1e6; | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i++) { | ||
if (i % 4 === 0) | ||
process.nextTick(onNextTick, i, true, 10, 'test'); | ||
else if (i % 3 === 0) | ||
process.nextTick(onNextTick, i, true, 10); | ||
else if (i % 2 === 0) | ||
process.nextTick(onNextTick, i, 20); | ||
else | ||
process.nextTick(onNextTick, i); | ||
} | ||
function onNextTick(i) { | ||
if (i + 1 === n) | ||
bench.end(+conf.millions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [5] | ||
}); | ||
|
||
function main(conf) { | ||
var n = +conf.millions * 1e6; | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i++) { | ||
process.nextTick(onNextTick, i); | ||
} | ||
function onNextTick(i) { | ||
if (i + 1 === n) | ||
bench.end(+conf.millions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters