Script Preparation code:
Tests:

Historical Performance Data aggregated from 81 community runs

Desktop Results:
Chrome 56 runs
Math.max.apply
907K/s
Math.max with spread
222K/s
for loop length caching
13K/s
basic for loop
9K/s

Fastest: Math.max.apply (104.1x faster)

View exact numbers
  • Math.max.apply: 906,753 ops/sec
  • Math.max with spread: 222,231 ops/sec
  • for loop length caching: 12,958 ops/sec
  • basic for loop: 8,712 ops/sec
Firefox 18 runs
for loop length caching
1.2M/s
basic for loop
1.1M/s
Math.max with spread
204K/s
Math.max.apply
203K/s

Fastest: for loop length caching (5.8x faster)

View exact numbers
  • for loop length caching: 1,184,136 ops/sec
  • basic for loop: 1,097,647 ops/sec
  • Math.max with spread: 203,701 ops/sec
  • Math.max.apply: 202,615 ops/sec
Mobile Results:
Safari 7 runs
Math.max.apply
477K/s
Math.max with spread
318K/s
for loop length caching
18K/s
basic for loop
13K/s

Fastest: Math.max.apply (37.4x faster)

View exact numbers
  • Math.max.apply: 477,035 ops/sec
  • Math.max with spread: 318,327 ops/sec
  • for loop length caching: 18,431 ops/sec
  • basic for loop: 12,740 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    Math.max.apply
    Math.max with spread
    basic for loop
    for loop length caching

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 10 months ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0
Firefox 143 on Ubuntu
View result in a separate tab
for loop length caching
1.2M/s
basic for loop
821K/s
Math.max with spread
289K/s
Math.max.apply
273K/s
View exact numbers
Test name Executions per second
for loop length caching 1,197,844 Ops/sec
basic for loop 821,205 Ops/sec
Math.max with spread 288,852 Ops/sec
Math.max.apply 273,224 Ops/sec