[function]bench runtime

Run Settings
LanguagePHP
Language Version
Run Command
<?php /** * first call bench() store start time * second call bench() get runtime from last time and reset start time * @example bench(); //start for($i = 0; $i < 1e6; $i++) { //do something } echo 'Execute Time: ' . bench(); */ function bench() { static $start; if (! $start) { $start = microtime(true); return; } $duration = microtime(true) - $start; $start = 0; return $duration; } bench(); echo "Hello \n"; echo 'Execute Time: ' . bench();
Editor Settings
Theme
Key bindings
Full width
Lines