The benchmark:
The invariants:
var f = function() { };
var g = function() { return this; }
The tests:
Below in order of expected speed
new f;
g.call(Object.create(Object.prototype));
new (function() { })
(function() { return this; }).call(Object.create(Object.prototype));
Actual speed :
new f;
g.call(Object.create(Object.prototype));
(function() { return this; }).call(Object.create(Object.prototype));
new (function() { })
The question:
- When you swap
f
andg
for inline anonymous functions. Why is thenew
(test 4.) test slower?
Update:
What specifically causes the new
to be slower when f
and g
are inlined.
I'm interested in references to the ES5 specification or references to JagerMonkey or V8 source code. (Feel free to link JSC and Carakan source code too. Oh and the IE team can leak Chakra source if they want to).
If you link any JS engine source, please explain it.