mirror of
https://github.com/google/benchmark.git
synced 2024-11-29 18:34:47 +00:00
819adb4cd1
* Add macros for create benchmark with templated fixture * Add info about templated fixtures to README.md * Add tests for templated fixtures
29 lines
493 B
C++
29 lines
493 B
C++
|
|
#include "benchmark/benchmark.h"
|
|
|
|
#include <cassert>
|
|
#include <memory>
|
|
|
|
template<typename T>
|
|
class MyFixture : public ::benchmark::Fixture {
|
|
public:
|
|
MyFixture() : data(0) {}
|
|
|
|
T data;
|
|
};
|
|
|
|
BENCHMARK_TEMPLATE_F(MyFixture, Foo, int)(benchmark::State &st) {
|
|
while (st.KeepRunning()) {
|
|
data += 1;
|
|
}
|
|
}
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) {
|
|
while (st.KeepRunning()) {
|
|
data += 1.0;
|
|
}
|
|
}
|
|
BENCHMARK_REGISTER_F(MyFixture, Bar);
|
|
|
|
BENCHMARK_MAIN()
|