diff --git a/src/Services/View.php b/src/Services/View.php index 04e95bf..7136dcc 100644 --- a/src/Services/View.php +++ b/src/Services/View.php @@ -59,7 +59,12 @@ protected function appendMs(array $data): array continue; } - $value = sprintf('%s ms - %s', $this->roundTime($value['time']), $this->roundRam($value['ram'])); + $time = $this->roundTime($value['time']); + $ram = $this->roundRam($value['ram'] ?? null); + + $value = ! empty($ram) + ? sprintf('%s ms - %s', $time, $ram) + : sprintf('%s ms', $time); } } @@ -75,8 +80,12 @@ protected function roundTime(float $value): float return $value; } - protected function roundRam(float|int $bytes): string + protected function roundRam(float|int|null $bytes): ?string { - return $this->memory->format((int) $bytes); + if ($bytes !== null) { + return $this->memory->format((int) $bytes); + } + + return null; } } diff --git a/src/Transformers/Stats.php b/src/Transformers/Stats.php index c43f3aa..232ffeb 100644 --- a/src/Transformers/Stats.php +++ b/src/Transformers/Stats.php @@ -42,7 +42,7 @@ protected function calculate(array $data): array } foreach ($data['total'] as $name => $value) { - $this->put($items, 'total', $name, fn () => ['time' => $value[0], 'ram' => $value[1]]); + $this->put($items, 'total', $name, fn () => ['time' => $value[0]]); } return $items; diff --git a/tests/TestCase.php b/tests/TestCase.php index dc66249..87cd3a5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -16,6 +16,6 @@ protected function benchmark(): Benchmark protected function work(): void { - usleep(50); + usleep(10); } }