Status: Accepted
Owner: [email protected]
Labels: Type-FeatureRequest Priority-Low
New issue 1325 by [email protected]: Make Math.min and Math.max faster
http://code.google.com/p/v8/issues/detail?id=1325
We can inline the code for the common case where Math.min and Math.max get
two integer or two double arguments. In the following test, the handwritten
version is about 2x faster than the generic built-in.
function min(a, b) {
return a < b ? a : b;
}
function f(x, y) { return min(x, y); }
function g(x, y) { return Math.min(x, y); }
var start = new Date();
for (var i=0; i<10000000; i++) f(42, 43);
print("elapsed: "+ (new Date() - start));
start = new Date();
for (var i=0; i<10000000; i++) g(42, 43);
print("elapsed: "+ (new Date() - start));
$ ./shell min.js
elapsed: 160
elapsed: 311
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev