Array loop vs foreach vs map fixed by bomi

Makes the benchmark actually measure the speed of for/foreach/map instead of slowing them down.
3 months ago
User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Test name Executions per second
foreach 388455.4 Ops/sec
for 246036.9 Ops/sec
map 64603.0 Ops/sec
Script Preparation code:
Tests:
  • foreach

  • for

  • map

Open this result on MeasureThat.net