Skip to content

Instantly share code, notes, and snippets.

@fhinkel
Forked from mafintosh/perf-test.js
Created October 19, 2016 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhinkel/42bebdaa56bc7fca537aae8c5518c245 to your computer and use it in GitHub Desktop.
Save fhinkel/42bebdaa56bc7fca537aae8c5518c245 to your computer and use it in GitHub Desktop.
var fs = require('fs')
for (var i = 0; i < 10000; i++) {
printLength(__filename)
}
function printLength (filename) {
fs.readFile(filename, foo)
function foo (err, buf) {
if (err) return // ignore error - probably just too many fds
console.error(filename + ' has length ' + buf.length)
}
}
@fhinkel
Copy link
Author

fhinkel commented Oct 31, 2016

foo is marked for optimization, but never optimized.

$ node --trace-opt perf-test.js
...
[marking 0x37192dd8fd79 <JS Function foo (SharedFunctionInfo 0xde0e275bcd1)> for optimized recompilation, reason: small function, ICs with typeinfo: 1/1 (100%), generic ICs: 0/1 (0%)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment