updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Timer;
interface Exception

View File

@@ -7,7 +7,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Timer;
final class RuntimeException extends \RuntimeException implements Exception

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of phpunit/php-timer.
*
@@ -7,22 +7,30 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Timer;
final class Timer
{
/**
* @var array
* @var int[]
*/
private static $sizes = [
'GB' => 1073741824,
'MB' => 1048576,
'KB' => 1024,
];
/**
* @var int[]
*/
private static $times = [
'hour' => 3600000,
'minute' => 60000,
'second' => 1000
'second' => 1000,
];
/**
* @var array
* @var float[]
*/
private static $startTimes = [];
@@ -36,6 +44,19 @@ final class Timer
return \microtime(true) - \array_pop(self::$startTimes);
}
public static function bytesToString(int $bytes): string
{
foreach (self::$sizes as $unit => $value) {
if ($bytes >= $value) {
$size = \sprintf('%.2f', $bytes >= 1024 ? $bytes / $value : $bytes);
return $size . ' ' . $unit;
}
}
return $bytes . ' byte' . ($bytes !== 1 ? 's' : '');
}
public static function secondsToTimeString(float $time): string
{
$ms = \round($time * 1000);
@@ -73,9 +94,9 @@ final class Timer
public static function resourceUsage(): string
{
return \sprintf(
'Time: %s, Memory: %4.2fMB',
'Time: %s, Memory: %s',
self::timeSinceStartOfRequest(),
\memory_get_peak_usage(true) / 1048576
self::bytesToString(\memory_get_peak_usage(true))
);
}
}