Files
phpy/docs/cn/benchmark/array.php
tianfenghan d669a42060 Update docs
2023-12-14 12:48:30 +08:00

21 lines
401 B
PHP

<?php
ini_set('memory_limit', '2G');
$dict = [];
const COUNT = 10000000;
$n = COUNT;
$s = microtime(true);
while ($n--) {
$dict['key-' . $n] = $n * 3;
}
echo 'array set: ' . round(microtime(true) - $s, 6) . ' seconds' . PHP_EOL;
$c = 0;
$n = COUNT;
$s = microtime(true);
while ($n--) {
$c += $dict['key-' . $n];
}
echo 'array get: ' . round(microtime(true) - $s, 6) . ' seconds' . PHP_EOL;