File: geometry.cpp

package info (click to toggle)
mapbox-geometry 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: cpp: 1,563; sh: 150; makefile: 37
file content (24 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <benchmark/benchmark.h>
#include <mapbox/geometry.hpp>
#include <random>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
static void BM_polygon_allocation(benchmark::State& state) // NOLINT google-runtime-references
{
    std::size_t s = state.range(0);
    std::default_random_engine generator;
    std::uniform_int_distribution<int> distribution(-99, 99);
    auto dice = std::bind(distribution, generator);
    while (state.KeepRunning())
    {
        mapbox::geometry::linear_ring<std::int64_t> r;
        r.reserve(s);
        r.emplace_back(dice(), dice());
    }
    state.SetLabel(std::to_string((s * 16) / 1024) + "kb");
}

BENCHMARK(BM_polygon_allocation)->Range(1024, 1 << 29);

#pragma GCC diagnostic pop