PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php # json_decode vs var_dump vs print_r error_reporting (1); ini_set('memory_limit', '512M'); class perf { private $times = []; private $start = null; public function start() { $this->start = microtime(true); } public function stop(string $label) { $this->times[$label] = microtime(true) - $this->start; } public function report() { asort($this->times, SORT_NUMERIC); $bench = current($this->times); foreach($this->times as $label => $time) { $time = number_format($time, 5); echo sprintf("%s%% %ss %s\n", number_format($time/$bench*100,1), $time, $label); } } } $p = new perf(); $steps = 10000; foreach(hash_algos() as $hash) { $p->start(); for($i=$steps;$i;$i--) { hash($hash, print_r($_SERVER, true)); } $p->stop($hash); } $p->report(); echo hash('xxh128', "Hallo Welt"), "\n"; echo hash('xxh32', "Hallo Welt"), "\n"; echo hash('crc32', "Hallo Welt"), "\n"; echo hash('crc32b', "Hallo Welt");
Show:  
Copy Clear