run code in 200+ php & hhvm versions
Bugs & Features
<?php // The test considers that the array may be associative $arrayExample = array_fill(0, 1000, 'hello'); $testsCount = 1000; $start = microtime(true); for ($i = 0; $i < $testsCount; ++$i) { $array = array_reverse($arrayExample); foreach ($array as $value) { // } } printf("array_reverse: %fs\n", microtime(true) - $start); $start = microtime(true); for ($i = 0; $i < $testsCount; ++$i) { $array = array_values($arrayExample); for ($j = count($array) - 1; $j >= 0; --$j) { $value = $array[$j]; } } printf("array_values %fs\n", microtime(true) - $start); $start = microtime(true); for ($i = 0; $i < $testsCount; ++$i) { $array = $arrayExample; while ($array) { $value = array_pop($array); } } printf("array_pop: %fs\n", microtime(true) - $start);
based on A9nKR
Output for 7.2.12
array_reverse: 0.013253s array_values 0.015237s array_pop: 0.050858s
Output for 7.2.11
array_reverse: 0.013457s array_values 0.015119s array_pop: 0.042077s
Output for 7.2.10
array_reverse: 0.014625s array_values 0.016035s array_pop: 0.037528s
Output for 7.2.9
array_reverse: 0.013505s array_values 0.016185s array_pop: 0.037909s
Output for 7.2.8
array_reverse: 0.016430s array_values 0.020662s array_pop: 0.040395s
Output for 7.2.7
array_reverse: 0.013794s array_values 0.015258s array_pop: 0.041083s
Output for 7.2.6
array_reverse: 0.016273s array_values 0.021728s array_pop: 0.055617s
Output for 7.2.5
array_reverse: 0.016433s array_values 0.021744s array_pop: 0.060762s
Output for 7.2.4
array_reverse: 0.014855s array_values 0.016528s array_pop: 0.042133s
Output for 7.2.3
array_reverse: 0.017528s array_values 0.018328s array_pop: 0.046141s
Output for 7.2.2
array_reverse: 0.013871s array_values 0.015414s array_pop: 0.045350s
Output for 7.2.1
array_reverse: 0.013852s array_values 0.015405s array_pop: 0.040994s
Output for 7.2.0
array_reverse: 0.013199s array_values 0.014955s array_pop: 0.049542s
Output for 7.1.24
array_reverse: 0.015004s array_values 0.021588s array_pop: 0.042152s
Output for 7.1.23
array_reverse: 0.013280s array_values 0.023480s array_pop: 0.042651s
Output for 7.1.22
array_reverse: 0.014262s array_values 0.021442s array_pop: 0.043432s
Output for 7.1.21
array_reverse: 0.024112s array_values 0.030495s array_pop: 0.050749s
Output for 7.1.20
array_reverse: 0.017520s array_values 0.027886s array_pop: 0.060463s
Output for 7.1.19
array_reverse: 0.014025s array_values 0.024087s array_pop: 0.049214s
Output for 7.1.18
array_reverse: 0.017065s array_values 0.027487s array_pop: 0.060559s
Output for 7.1.17
array_reverse: 0.018874s array_values 0.027910s array_pop: 0.060332s
Output for 7.1.16
array_reverse: 0.019962s array_values 0.035632s array_pop: 0.062318s
Output for 7.1.15
array_reverse: 0.020638s array_values 0.032914s array_pop: 0.066930s
Output for 7.1.14
array_reverse: 0.016325s array_values 0.023974s array_pop: 0.049299s
Output for 7.1.13
array_reverse: 0.013491s array_values 0.021712s array_pop: 0.043370s
Output for 7.1.12
array_reverse: 0.014423s array_values 0.023151s array_pop: 0.049108s
Output for 7.1.11
array_reverse: 0.013450s array_values 0.021128s array_pop: 0.054250s
Output for 7.1.10
array_reverse: 0.013017s array_values 0.021087s array_pop: 0.047445s
Output for 7.1.9
array_reverse: 0.015744s array_values 0.021968s array_pop: 0.044249s
Output for 7.1.8
array_reverse: 0.013305s array_values 0.022683s array_pop: 0.041346s
Output for 7.1.7
array_reverse: 0.024972s array_values 0.025251s array_pop: 0.050516s
Output for 7.1.6
array_reverse: 0.015798s array_values 0.020604s array_pop: 0.041432s
Output for 7.1.5
array_reverse: 0.013336s array_values 0.023299s array_pop: 0.047530s
Output for 7.1.4
array_reverse: 0.016864s array_values 0.023600s array_pop: 0.048459s
Output for 7.1.3
array_reverse: 0.014250s array_values 0.024296s array_pop: 0.042675s
Output for 7.1.2
array_reverse: 0.015195s array_values 0.022826s array_pop: 0.053848s
Output for 7.1.1
array_reverse: 0.012909s array_values 0.021176s array_pop: 0.053490s
Output for 7.1.0
array_reverse: 0.012988s array_values 0.020707s array_pop: 0.042632s
Output for 7.0.32
array_reverse: 0.018600s array_values 0.025098s array_pop: 0.043740s
Output for 5.6.38
array_reverse: 0.087179s array_values 0.074928s array_pop: 0.139517s