Pre-array or function calls
Date tested:
7 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2959.0 Safari/537.36
Test name
Executions per second
test1
3649155.0 Ops/sec
test2
3768556.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var xOffset = 0; var xScale = 1; var i = 0, l = 10000000; function getX( index ) { return xOffset + index * xScale; } var tot = 0;
Tests:
test1
for( ;i < l; i ++ ) { tot += getX( i ); }
test2
for( ;i < l; i ++ ) { tot += xOffset + i * xScale; }
Open this result on MeasureThat.net