2022-04-16 11:41:48 +02:00
|
|
|
//
|
|
|
|
// Created by maximilian on 16.04.22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <benchmark/benchmark.h>
|
|
|
|
|
|
|
|
#include "areas.h"
|
|
|
|
|
|
|
|
static void BM_area_computation(benchmark::State& state) {
|
|
|
|
std::vector<Rectangle> rects;
|
|
|
|
for (auto _ : state) {
|
|
|
|
state.PauseTiming();
|
|
|
|
rects = get_random_instance(state.range(0), state.range(1));
|
|
|
|
state.ResumeTiming();
|
|
|
|
get_area_union(rects);
|
|
|
|
}
|
|
|
|
state.SetComplexityN(state.range(0));
|
|
|
|
}
|
|
|
|
|
2022-04-16 21:18:34 +02:00
|
|
|
static std::vector<Rectangle> get_inst() {
|
|
|
|
srand(17);
|
|
|
|
static std::vector<Rectangle> rects = get_random_instance(1 << 18, 1<<20);
|
|
|
|
return rects;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void BM_single(benchmark::State& state) {
|
|
|
|
for(auto _ :state) {
|
|
|
|
get_area_union(get_inst());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK(BM_single);
|
|
|
|
|
2022-04-16 11:41:48 +02:00
|
|
|
// add benchmark
|
2022-04-16 21:08:02 +02:00
|
|
|
// BENCHMARK(BM_area_computation)->ArgsProduct({benchmark::CreateRange(1<<4,1<<18,4),{1<<20}})->Complexity(benchmark::oNLogN);
|
2022-04-16 11:41:48 +02:00
|
|
|
|
|
|
|
// run benchmark as main()
|
2022-04-16 20:29:07 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
srand(876);
|
|
|
|
::benchmark::Initialize(&argc, argv);
|
|
|
|
if (::benchmark::ReportUnrecognizedArguments(argc, argv))return 1;
|
|
|
|
::benchmark::RunSpecifiedBenchmarks();
|
|
|
|
::benchmark::Shutdown();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int, char **);
|