Last active
February 8, 2017 02:46
-
-
Save dg3feiko/4850a233861137f92b61d335398a105a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function foo(cb) { | |
cb(); | |
} | |
console.time("anonymous function"); | |
for (var i = 0; i < 10000000; i++) { | |
foo(function () { }); | |
} | |
console.timeEnd("anonymous function"); | |
/// | |
console.time("named function"); | |
function CB(){} | |
for (var i = 0; i < 10000000; i++) { | |
foo(CB); | |
} | |
console.timeEnd("named function"); | |
/// | |
console.time("node-noop"); | |
var noop = require('node-noop').noop; | |
for (var i = 0; i < 10000000; i++) { | |
foo(noop); | |
} | |
console.timeEnd("node-noop"); | |
/* | |
anonymous function: 197.868ms | |
named function: 65.239ms | |
node-noop: 58.326ms | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment