[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/abellgithub/delaunator-cpp/master/bench/run.cpp [Back]  [Original]

#include "../examples/utils.hpp"
#include 
#include 
#include 
#include 
#include 
#include 

std::vector generate_uniform(std::size_t n) {
    std::vector coords;
    coords.reserve(2 * n);
    std::srand(350);
    double norm = static_cast(RAND_MAX) / 1e3;
    for (size_t i = 0; i < n; i++) {
        coords.push_back(static_cast(std::rand()) / norm);
        coords.push_back(static_cast(std::rand()) / norm);
    }

    return coords;
}

void BM_45K_geojson_nodes(benchmark::State& state) {
    std::string points_str = utils::read_file("./test-files/osm-nodes-45331-epsg-3857.geojson");
    std::vector coords = utils::get_geo_json_points(points_str);

    while (state.KeepRunning()) {
        delaunator::Delaunator delaunator(coords);
    }
}

void BM_uniform(benchmark::State& state) {
    std::vector coords = generate_uniform(static_cast(state.range(0)));
    while (state.KeepRunning()) {
        delaunator::Delaunator delaunator(coords);
    }
    state.SetComplexityN(state.range(0));
}

class MyFixture : public ::benchmark::Fixture
{
public:
    MyFixture() : vals(generate_uniform(10000000))
    {
    }

    virtual void SetUp(::benchmark::State&)
    {}

    virtual void TearDown(::benchmark::State&)
    {}

    std::vector vals;
};

/**
BENCHMARK_DEFINE_F(MyFixture, minmax)(::benchmark::State&state)
{
    std::cerr Arg(1000000)->Unit(benchmark::kMillisecond);

#if BENCHMARK_BIG_O
BENCHMARK(BM_uniform)->RangeMultiplier(2)->Range(1 Complexity();
#endif
#if BENCHMARK_10M
BENCHMARK(BM_uniform)->Arg(1000000 * 10)->Unit(benchmark::kMillisecond);
#endif
#if BENCHMARK_100M
BENCHMARK(BM_uniform)->Arg(1000000 * 100)->Unit(benchmark::kMillisecond);
#endif

BENCHMARK_MAIN()

Web Proxy Viewer  |  New URL  |  Original Page