mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 21:10:19 +08:00
4c2af07889
* format all documents according to contributor guidelines and specifications use clang-format on/off to stop formatting when it makes excessively poor decisions * format all tests as well, and mark blocks which change too much
29 lines
482 B
C++
29 lines
482 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) {
|
|
for (auto _ : st) {
|
|
data += 1;
|
|
}
|
|
}
|
|
|
|
BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) {
|
|
for (auto _ : st) {
|
|
data += 1.0;
|
|
}
|
|
}
|
|
BENCHMARK_REGISTER_F(MyFixture, Bar);
|
|
|
|
BENCHMARK_MAIN();
|