The static factory method start has been renamed to make:
// Before
Benchmark::start()
// After
Benchmark::make()The prepare method has been renamed to beforeEach:
// Before
Benchmark::start()
->prepare(function (string $name, int $iteration) {
// ...
})
// After
Benchmark::make()
->beforeEach(function (string $name, int $iteration) {
// ...
})The compare method now returns static instead of void. To get results, you must explicitly call one of the output methods:
toConsole()— prints the result table to the consoletoData()— returns an array ofResultDataobjectstoAssert()— returns anAssertServiceinstance for assertions
// Before
Benchmark::start()
->compare(
fn () => /* ... */,
fn () => /* ... */,
);
// After
Benchmark::make()
->compare(
fn () => /* ... */,
fn () => /* ... */,
)
->toConsole();The withoutData method has been removed without replacement.
All fluent methods (iterations, round, beforeEach, afterEach, before, after, compare, toConsole) now return static instead of self for better extensibility.
The DragonCode\Benchmark\Contracts\Transformer interface has been removed. If you implemented this interface, use the new ResultTransformer class instead.
The exception now accepts a mixed value (the actual object) instead of a string type name:
// Before
throw new ValueIsNotCallableException(gettype($value));
// After
throw new ValueIsNotCallableException($value);- Removed
dragon-code/supportdependency - Removed
symfony/consoledependency - Added
symfony/polyfill-php85dependency
If your project relied on dragon-code/support or symfony/console being pulled in transitively, you must now require them directly.
All service classes now have a Service suffix:
| Before (3.x) | After (4.x) |
|---|---|
Services\Arr |
Removed |
Services\MeasurementError |
Services\MeasurementErrorService |
Services\Memory |
Services\MemoryService |
Services\Runner |
Services\RunnerService |
Services\View |
Services\ViewService |
All view classes now have a View suffix:
| Before (3.x) | After (4.x) |
|---|---|
View\ProgressBar |
View\ProgressBarView |
View\Table |
View\TableView |
The old transformer classes (Base, Separator, Stats, Times, Transformer, Winner) have been removed and replaced with a single ResultTransformer class.
The DragonCode\Benchmark\Services\Arr class has been removed without replacement.
New DTO classes have been introduced:
DragonCode\Benchmark\Data\ResultDataDragonCode\Benchmark\Data\MetricData
New lifecycle callback methods have been added:
before(Closure $callback)— called once before each named callback groupafter(Closure $callback)— called once after each named callback groupafterEach(Closure $callback)— called after each iteration
All internal references to ram have been renamed to memory for consistency.
The assert method has been renamed to toAssert and now returns an AssertService instance instead of static.