Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use function abs;
use function array_first;
use function count;
use function func_get_args;
use function is_array;
use function is_callable;
use function max;
Expand Down Expand Up @@ -103,12 +102,10 @@ public function round(?int $precision): static

public function compare(array|Closure ...$callbacks): static
{
$values = $this->resolveCallbacks(
func_get_args() ?: $callbacks
);

$this->clear();

$values = $this->resolveCallbacks($callbacks);

$this->withProgress($values, $this->steps($values));

return $this;
Expand Down
14 changes: 14 additions & 0 deletions tests/Unit/Compares/AsArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@
1,
]);
});

test('mixed names', function () {
$results = benchmark(false)->compare([
static fn () => true,
'foo' => static fn () => true,
'bar' => static fn () => false,
])->toData();

expect($results)->toHaveKeys([
0,
'foo',
'bar',
]);
});
14 changes: 14 additions & 0 deletions tests/Unit/Compares/AsCallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@
1,
]);
});

test('mixed names', function () {
$results = benchmark(false)->compare(
static fn () => true,
foo: static fn () => true,
bar: static fn () => false,
)->toData();

expect($results)->toHaveKeys([
0,
'foo',
'bar',
]);
});