As of today's twitter thread and related example, it is currently not supported to run benchmarks and reset state at each execution of the benchmark methods.
Basically:
class MyBench
{
public function __construct()
{
$this->foo = new Foo();
}
public function benchFoo()
{
$this->foo->reset(); // <- should not be included in benchmark measurement
$this->foo->doFoo();
}
}
A workaround (for now), is to ensure immutability by de-referencing the system under bench:
class MyBench
{
public function __construct()
{
$this->foo = new Foo();
}
public function benchFoo()
{
$foo = clone $this->foo; // <- still some overhead
$foo->doFoo();
}
}
This needs some research, but it may be possible to have a separate resetInstance method (or such) on the benchmark, that can be measured and excluded from the output measurements.
As of today's twitter thread and related example, it is currently not supported to run benchmarks and reset state at each execution of the benchmark methods.
Basically:
A workaround (for now), is to ensure immutability by de-referencing the system under bench:
This needs some research, but it may be possible to have a separate
resetInstancemethod (or such) on the benchmark, that can be measured and excluded from the output measurements.