2017-10-10 03:10:37 +08:00
|
|
|
|
|
|
|
#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) {
|
2017-10-18 02:17:02 +08:00
|
|
|
for (auto _ : st) {
|
2017-10-10 03:10:37 +08:00
|
|
|
data += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) {
|
2017-10-18 02:17:02 +08:00
|
|
|
for (auto _ : st) {
|
2017-10-10 03:10:37 +08:00
|
|
|
data += 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BENCHMARK_REGISTER_F(MyFixture, Bar);
|
|
|
|
|
|
|
|
BENCHMARK_MAIN()
|