Skip to content

Allow comparing two (or more) different benchmark methods to each other in the same run. #1120

Description

@stepo2

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions