Skip to content

Commit

Permalink
Merge pull request #14 from TheDragonCode/2.x
Browse files Browse the repository at this point in the history
2.x
  • Loading branch information
andrey-helldar authored Jul 4, 2023
2 parents 5c8bfec + b2fc1b5 commit c2e3342
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/Services/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/Transformers/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ protected function benchmark(): Benchmark

protected function work(): void
{
usleep(50);
usleep(10);
}
}

0 comments on commit c2e3342

Please sign in to comment.