Skip to content

Instantly share code, notes, and snippets.

@fhinkel
Last active November 17, 2016 10:34
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/965e778d27cd39a943a855003fde6aea to your computer and use it in GitHub Desktop.
Save fhinkel/965e778d27cd39a943a855003fde6aea to your computer and use it in GitHub Desktop.
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);
}
}
@fhinkel
Copy link
Author

fhinkel commented Nov 17, 2016

~/v8 (master)$ time ./out.gn/x64.debug/d8 perf-test.js --mark_shared_functions_for_tier_up
real	0m0.385s
user	0m0.368s
sys	0m0.020s
~/v8 (master)$ time ./out.gn/x64.debug/d8 perf-test.js 
real	0m1.533s
user	0m1.515s
sys	0m0.026s

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