2017-10-09 19:10:37 +00:00
|
|
|
|
|
|
|
#include "benchmark/benchmark.h"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <memory>
|
|
|
|
|
2018-06-01 10:14:19 +00:00
|
|
|
template <typename T>
|
2017-10-09 19:10:37 +00:00
|
|
|
class MyFixture : public ::benchmark::Fixture {
|
2018-06-01 10:14:19 +00:00
|
|
|
public:
|
2017-10-09 19:10:37 +00:00
|
|
|
MyFixture() : data(0) {}
|
|
|
|
|
|
|
|
T data;
|
|
|
|
};
|
|
|
|
|
2018-06-01 10:14:19 +00:00
|
|
|
BENCHMARK_TEMPLATE_F(MyFixture, Foo, int)(benchmark::State& st) {
|
2017-10-17 18:17:02 +00:00
|
|
|
for (auto _ : st) {
|
2017-10-09 19:10:37 +00:00
|
|
|
data += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) {
|
2017-10-17 18:17:02 +00:00
|
|
|
for (auto _ : st) {
|
2017-10-09 19:10:37 +00:00
|
|
|
data += 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(MyFixture, Bar);
|
|
|
|
|
2017-12-04 01:45:07 +00:00
|
|
|
BENCHMARK_MAIN();
|