|
| 1 | +#include "rand_array.h" |
| 2 | +#include "x86simdsort.h" |
| 3 | +#include <benchmark/benchmark.h> |
| 4 | + |
| 5 | +#define MY_BENCHMARK_CAPTURE(func, T, test_case_name, ...) \ |
| 6 | + BENCHMARK_PRIVATE_DECLARE(func) \ |
| 7 | + = (::benchmark::internal::RegisterBenchmarkInternal( \ |
| 8 | + new ::benchmark::internal::FunctionBenchmark( \ |
| 9 | + #func "/" #test_case_name "/" #T, \ |
| 10 | + [](::benchmark::State &st) { \ |
| 11 | + func<T>(st, __VA_ARGS__); \ |
| 12 | + }))) |
| 13 | + |
| 14 | +#define BENCH_SORT(func, type) \ |
| 15 | + MY_BENCHMARK_CAPTURE( \ |
| 16 | + func, type, random_128, 128, std::string("random")); \ |
| 17 | + MY_BENCHMARK_CAPTURE( \ |
| 18 | + func, type, random_256, 256, std::string("random")); \ |
| 19 | + MY_BENCHMARK_CAPTURE( \ |
| 20 | + func, type, random_512, 512, std::string("random")); \ |
| 21 | + MY_BENCHMARK_CAPTURE( \ |
| 22 | + func, type, random_1k, 1024, std::string("random")); \ |
| 23 | + MY_BENCHMARK_CAPTURE(func, type, random_5k, 5000, std::string("random")); \ |
| 24 | + MY_BENCHMARK_CAPTURE( \ |
| 25 | + func, type, random_100k, 100000, std::string("random")); \ |
| 26 | + MY_BENCHMARK_CAPTURE( \ |
| 27 | + func, type, random_1m, 1000000, std::string("random")); \ |
| 28 | + MY_BENCHMARK_CAPTURE( \ |
| 29 | + func, type, random_10m, 10000000, std::string("random")); \ |
| 30 | + MY_BENCHMARK_CAPTURE( \ |
| 31 | + func, type, smallrange_128, 128, std::string("smallrange")); \ |
| 32 | + MY_BENCHMARK_CAPTURE( \ |
| 33 | + func, type, smallrange_256, 256, std::string("smallrange")); \ |
| 34 | + MY_BENCHMARK_CAPTURE( \ |
| 35 | + func, type, smallrange_512, 512, std::string("smallrange")); \ |
| 36 | + MY_BENCHMARK_CAPTURE( \ |
| 37 | + func, type, smallrange_1k, 1024, std::string("smallrange")); \ |
| 38 | + MY_BENCHMARK_CAPTURE(func, type, smallrange_5k, 5000, std::string("smallrange")); \ |
| 39 | + MY_BENCHMARK_CAPTURE( \ |
| 40 | + func, type, smallrange_100k, 100000, std::string("smallrange")); \ |
| 41 | + MY_BENCHMARK_CAPTURE( \ |
| 42 | + func, type, smallrange_1m, 1000000, std::string("smallrange")); \ |
| 43 | + MY_BENCHMARK_CAPTURE( \ |
| 44 | + func, type, smallrange_10m, 10000000, std::string("smallrange")); \ |
| 45 | + MY_BENCHMARK_CAPTURE( \ |
| 46 | + func, type, sorted_10k, 10000, std::string("sorted")); \ |
| 47 | + MY_BENCHMARK_CAPTURE( \ |
| 48 | + func, type, constant_10k, 10000, std::string("constant")); \ |
| 49 | + MY_BENCHMARK_CAPTURE( \ |
| 50 | + func, type, reverse_10k, 10000, std::string("reverse")); |
| 51 | + |
| 52 | +#define BENCH_PARTIAL(func, type) \ |
| 53 | + MY_BENCHMARK_CAPTURE(func, type, k10, 10000, 10); \ |
| 54 | + MY_BENCHMARK_CAPTURE(func, type, k100, 10000, 100); \ |
| 55 | + MY_BENCHMARK_CAPTURE(func, type, k1000, 10000, 1000); \ |
| 56 | + MY_BENCHMARK_CAPTURE(func, type, k5000, 10000, 5000); |
0 commit comments