Skip to content

Instantly share code, notes, and snippets.

@paulfryzel
Created June 22, 2015 19:02
Show Gist options
  • Save paulfryzel/a0e5c8ff31a101990840 to your computer and use it in GitHub Desktop.
Save paulfryzel/a0e5c8ff31a101990840 to your computer and use it in GitHub Desktop.
'use strict';
function foo(a, b, c) {
return 0;
}
function Obj() {};
Obj.prototype.wrap = function(a, b, c) {
return foo.call(this, a, b, c);
}
var RUNS = 1e6;
var o = new Obj();
(function a0() {
var start = Date.now();
for (var i = 0; i < RUNS; i++) o.wrap();
print((Date.now() - start) / 1000, 's');
})();
(function a1() {
var start = Date.now();
for (var i = 0; i < RUNS; i++) o.wrap(1);
print((Date.now() - start) / 1000, 's');
})();
(function a3() {
var start = Date.now();
for (var i = 0; i < RUNS; i++) o.wrap(1, 2);
print((Date.now() - start) / 1000, 's');
})();
(function a4() {
var start = Date.now();
for (var i = 0; i < RUNS; i++) o.wrap(1, 2, 3);
print((Date.now() - start) / 1000, 's');
})();
@paulfryzel
Copy link
Author

$ ../vendor/v8/out/native/d8 --trace_hydrogen --trace_phase=Z --trace_deopt --code_comments --hydrogen_track_positions --print_opt_code pwqeth04y.js 
Concurrent recompilation has been disabled for tracing.
[removing optimized code for: a0]
0.006 s
[removing optimized code for: a1]
0.004 s
[removing optimized code for: a3]
0.003 s
[removing optimized code for: a4]
0.003 s
$ ../vendor/v8/out/native/d8 --turbo --trace_turbo --trace_phase=Z --trace_deopt --code_comments --turbo_source_positions --print_opt_code pwqeth04y.js 
---------------------------------------------------
Begin compiling method Obj.wrap using Turbofan
---------------------------------------------------
Finished compiling method Obj.wrap using Turbofan
---------------------------------------------------
Begin compiling method foo using Turbofan
---------------------------------------------------
Finished compiling method foo using Turbofan
---------------------------------------------------
Begin compiling method a0 using Turbofan
---------------------------------------------------
Finished compiling method a0 using Turbofan
0.072 s
---------------------------------------------------
Begin compiling method a1 using Turbofan
---------------------------------------------------
Finished compiling method a1 using Turbofan
0.065 s
---------------------------------------------------
Begin compiling method a3 using Turbofan
---------------------------------------------------
Finished compiling method a3 using Turbofan
0.062 s
---------------------------------------------------
Begin compiling method a4 using Turbofan
---------------------------------------------------
Finished compiling method a4 using Turbofan
0.057 s

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