Skip to content

Commit 426f12c

Browse files
authored
[9.x] Formats benchmarkables on dd call (#44297)
* Formats benchmarkables on `dd` * Makes measure available to receive closure or array * Fixes types
1 parent 278c6d7 commit 426f12c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Illuminate/Support/Benchmark.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public static function measure(Closure|array $benchmarkables, int $iterations =
4141
*/
4242
public static function dd(Closure|array $benchmarkables, int $iterations = 1): void
4343
{
44-
dd(static::measure($benchmarkables, $iterations));
44+
$result = collect(static::measure(Arr::wrap($benchmarkables), $iterations))
45+
->map(fn ($average) => number_format($average, 3).'ms')
46+
->when($benchmarkables instanceof Closure, fn ($c) => $c->first(), fn ($c) => $c->all());
47+
48+
dd($result);
4549
}
4650
}

0 commit comments

Comments
 (0)