-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
- Loading branch information
1 parent
2fc86de
commit 7e247c1
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