1
0
mirror of https://github.com/php/php-src.git synced 2026-04-03 14:12:38 +02:00
Files
archived-php-src/ext/hash/bench.php
Nikita Popov e0ea3e8a01 Remove dated results from ext/hash/bench.php
These are not exactly representative anymore.
2020-10-26 12:25:00 +01:00

26 lines
503 B
PHP
Executable File

#!/usr/bin/env php
<?php
error_reporting(E_ALL);
$data = file_get_contents(__FILE__);
$time = array();
foreach (hash_algos() as $algo) {
$time[$algo] = 0;
}
for ($j = 0; $j < 10; $j++) {
foreach (hash_algos() as $algo) {
$start = microtime(true);
for ($i = 0; $i < 1000; $i++) {
hash($algo, $data);
}
$time[$algo] += microtime(true)-$start;
}
}
asort($time, SORT_NUMERIC);
foreach ($time as $a => $t) {
printf("%-12s %02.6f\n", $a, $t);
}