<?php
ini_set('memory_limit', '-1');
$ary1 = array();
$ary2 = array();
$timeBegin = time();
for ($i = 0; $i <= 1000000; $i++) {
$ary1[] = $i;
}
$timeEnd1 = time();
for ($i = 0; $i <= 1000000; $i++) {
array_push($ary2, $i);
}
$timeEnd2 = time();
var_dump($timeBegin, $timeEnd1, $timeEnd2);
echo 'first loop take ' . ($timeEnd1 - $timeBegin) . ' seconds' . PHP_EOL;
echo 'second loop take ' . ($timeEnd2 - $timeEnd1) . ' seconds' . PHP_EOL;
- Output for 7.0.0 - 7.0.10, 7.1.0, 7.1.6 - 7.1.20, 7.1.28 - 7.1.30, 7.1.32 - 7.1.33, 7.2.17 - 7.2.25, 7.3.0 - 7.3.1, 7.3.4 - 7.3.5, 7.3.7 - 7.3.10, 7.4.0
- int(1452047806)
int(1452047806)
int(1452047806)
first loop take 0 seconds
second loop take 0 seconds
- Output for 7.3.11 - 7.3.12
- int(1452047807)
int(1452047807)
int(1452047807)
first loop take 0 seconds
second loop take 0 seconds
- Output for 7.1.26, 7.2.5 - 7.2.6, 7.3.2 - 7.3.3, 7.3.6
- int(1452047806)
int(1452047807)
int(1452047807)
first loop take 1 seconds
second loop take 0 seconds
- Output for 7.1.27, 7.1.31
- int(1452047806)
int(1452047806)
int(1452047807)
first loop take 0 seconds
second loop take 1 seconds
- Output for 7.0.20, 7.1.5
- int(1452047806)
int(1452047806)
int(1452047808)
first loop take 0 seconds
second loop take 2 seconds
- Output for 5.6.25 - 5.6.28
- Fatal error: Out of memory (allocated 259522560) (tried to allocate 72 bytes) in /in/JBk3l on line 11
Process exited with code 255. - Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.24
- Fatal error: Out of memory (allocated 258998272) (tried to allocate 72 bytes) in /in/JBk3l on line 11
Process exited with code 255.
preferences:
110.41 ms | 402 KiB | 120 Q