You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
482 B

2 months ago
  1. #include <cassert>
  2. #include <memory>
  3. #include "benchmark/benchmark.h"
  4. template <typename T>
  5. class MyFixture : public ::benchmark::Fixture {
  6. public:
  7. MyFixture() : data(0) {}
  8. T data;
  9. };
  10. BENCHMARK_TEMPLATE_F(MyFixture, Foo, int)(benchmark::State& st) {
  11. for (auto _ : st) {
  12. data += 1;
  13. }
  14. }
  15. BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) {
  16. for (auto _ : st) {
  17. data += 1.0;
  18. }
  19. }
  20. BENCHMARK_REGISTER_F(MyFixture, Bar);
  21. BENCHMARK_MAIN();