-
-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Let's say I have two functions that do the same, on different ways:
final class MathUtil
{
public static function heavyCalculationWayOne(): float
{
// ...
}
public static function heavyCalculationWayTwo(): float
{
// ...
}
}
And then I benchmark both with the same revolutions and/or iterations.
final class HeavyCalcBench
{
function benchWayOne(): void
{
MathUtil::heavyCalculationWayOne();
}
function benchWayTwo(): void
{
MathUtil::heavyCalculationWayTwo();
}
}
It would be nice if one could somehow mark one as the baseline for the others inside a single phpbench run process. To easily see on a single glance if or which one performs better. Currently I have to evualate the runtimes, memory, standard deviations, ... of both manually to each other. Basically what regression testing is doing but instead inside a single run on method level.
An example use-case is when a computationally heavy task is to be solved and different devs try their approaches - to then decide which makes it into the final product. Another one: on new PHP major versions, to check if the PHP interpreter can now handle both ways roughly the same as fast, so a real-world application can now use the better readible/maintainable method instead of the unreadible-but-more-optimized one.