Ben - C++ Benchmark

Meet Ben! The simple, modern, objects-oriented and dependencies free Benchmark framework for C++. This framework allows quick prototyping of pereformance tests of C++ functions using modern C++. Despite it's simplicity Ben can handle even more complex functions.

The best way to get to know Ben(chmark) better is to see the simple usage example:

#include "ben.h"

using namespace ben;

struct input
{
    int a;
    int b;
};

void add(const struct input *in, int &c)
{
    c = in->a + in->b;
}

class AdderTestSuite : public TestSuite
{
private:
    struct input* in;
    int c;
public:
    void setup() override
    {
        in = new input;
        c = 0;
    }

    void execute() override
    {
        run_test(add, in, c);

        run_test(add, in, c);

        run_test(add, in, c);

    }

    void cleanup() override {
        delete in;
    }
};

int main() {

    AdderTestSuite suite;
    suite.run_test_suite();

    return 0;
}

To run the application Ben has to be built first - it's uses CMake so it's really simple. After that just compile the code above (don't forget to link Ben to your executable).

Example output:

[  SUITE   ]
[ RUN      ]
[----------] Mean: 55.996
[----------] Stddev: 4.30068
[     DONE ]
[ RUN      ]
[----------] Mean: 11.851
[----------] Stddev: 0.0851213
[     DONE ]
[ RUN      ]
[----------] Mean: 12.274
[----------] Stddev: 0.127432
[     DONE ]
[   SUITE  ]

And that's all. You see Ben is really friendly.

Built With

Share this project:

Updates