Last active
November 17, 2016 10:34
-
-
Save fhinkel/965e778d27cd39a943a855003fde6aea 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
var fs = { | |
readFile: function(filename, cb) { | |
cb(null, {length: 12}); | |
} | |
} | |
for (var i = 0; i < 10000; i++) { | |
var __filename = 'perf-test.js'; | |
printLength(__filename) | |
} | |
function printLength (filename) { | |
fs.readFile(filename, foo) | |
function foo (err, buf) { | |
if (err) return // ignore error - probably just too many fds | |
for (var j = 0; j<1000; j++) { | |
// Do some work to make the optimization actually worth while | |
buf.length++; | |
} | |
return (filename + ' has length ' + buf.length); | |
} | |
} |
Author
fhinkel
commented
Nov 17, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment