-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: remove Reflect.apply where appropriate
Using Reflect.apply where the callback context does not need to change is unnecessary and less performant. PR-URL: #27349 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
- Loading branch information
1 parent
8495e8b
commit 9c842f4
Showing
5 changed files
with
52 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e6], | ||
}); | ||
|
||
function main({ n }) { | ||
var j = 0; | ||
function cb1(arg1) { | ||
j++; | ||
if (j === n) | ||
bench.end(n); | ||
} | ||
function cb2(arg1, arg2) { | ||
j++; | ||
if (j === n) | ||
bench.end(n); | ||
} | ||
function cb3(arg1, arg2, arg3) { | ||
j++; | ||
if (j === n) | ||
bench.end(n); | ||
} | ||
function cb4(arg1, arg2, arg3, arg4) { | ||
j++; | ||
if (j === n) | ||
bench.end(n); | ||
} | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i++) { | ||
if (i % 4 === 0) | ||
setTimeout(cb4, 1, 3.14, 1024, true, false); | ||
else if (i % 3 === 0) | ||
setTimeout(cb3, 1, 512, true, null); | ||
else if (i % 2 === 0) | ||
setTimeout(cb2, 1, false, 5.1); | ||
else | ||
setTimeout(cb1, 1, 0); | ||
} | ||
} |
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