diff --git a/src/StopWatch.php b/src/StopWatch.php deleted file mode 100644 index 09e1099..0000000 --- a/src/StopWatch.php +++ /dev/null @@ -1,96 +0,0 @@ - self::$max[$name]) { - self::$max[$name] = $time; - self::$maxlabels[$name] = $label; - } - unset(self::$starts[$name]); - } - - public function getTimings(): string - { - $total = 0; - foreach(self::$timings as $timing) { - $total += $timing; - } - - $texts = ['', '--- StopWatch timings ----------------']; - foreach(self::$timings as $name => $time) { - $texts[] = $name . '*' . self::$counters[$name] - . ': tot. ' . self::formatTime($time) - . ', ' . self::formatPercent($time / $total) - . ', avg. '. self::formatTime($time / self::$counters[$name]) - . ', min. '. self::formatTime(self::$min[$name]) - . ', max. '. self::formatTime(self::$max[$name]) - . (empty(self::$maxlabels[$name]) ? '' : '(' . self::$maxlabels[$name] . ')'); - } - $texts[] = '--------------------------------------'; - return implode("\n", $texts); - } - - private function formatTime(float $seconds): string - { - if ($seconds >= 60) { - return (int)($seconds / 60).'min'; - } - else if ($seconds >= 1) { - return (int)($seconds).'s'; - } - else if ($seconds >= 0.001) { - return (int)($seconds * 1000).'ms'; - } - else if ($seconds >= 0.000001) { - return (int)($seconds * 1000000).'us'; - } - else { - return '0'; - } - } - - private function formatPercent(float $fraction): string - { - return number_format($fraction * 100, 1) . '%'; - } -} \ No newline at end of file