Last active
November 17, 2016 10:34
-
-
Save fhinkel/965e778d27cd39a943a855003fde6aea to your computer and use it in GitHub Desktop.
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
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); | |
} | |
} |
~/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
Adapted from https://gist.github.com/fhinkel/42bebdaa56bc7fca537aae8c5518c245 to work without Node.js.
For progress, see https://bugs.chromium.org/p/v8/issues/detail?id=5512#c34.