File: PointLocatorPerfTest.cpp

package info (click to toggle)
geos 3.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,212 kB
  • sloc: cpp: 199,103; xml: 56,065; ansic: 6,162; sh: 287; makefile: 26
file content (50 lines) | stat: -rw-r--r-- 1,741 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2021 Daniel Baston
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#include <benchmark/benchmark.h>

#include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
#include <geos/algorithm/locate/SimplePointInAreaLocator.h>

#include <BenchmarkUtils.h>

using geos::algorithm::locate::SimplePointInAreaLocator;
using geos::algorithm::locate::IndexedPointInAreaLocator;

auto nPtsRange = benchmark::CreateRange(4, 8000, 2);
auto nTestsRange = benchmark::CreateDenseRange(1, 20, 1);

template<class Locator>
static void BM_PointInAreaLocator(benchmark::State& state) {
    std::default_random_engine eng(12345);

    auto nRingPts = static_cast<std::size_t>(state.range(0));
    auto nTestPts = static_cast<std::size_t>(state.range(1));

    auto geom = geos::benchmark::createSineStar({0, 0}, 100, nRingPts);

    auto test_pts = geos::benchmark::createRandomCoords(*geom->getEnvelopeInternal(), nTestPts, eng);

    for (auto _ : state) {
        Locator loc(*geom);
        for (const auto& coord : test_pts->items<geos::geom::CoordinateXY>()) {
            loc.locate(&coord);
        }
    }
}

BENCHMARK_TEMPLATE(BM_PointInAreaLocator, IndexedPointInAreaLocator)->ArgsProduct({nPtsRange, nTestsRange});
BENCHMARK_TEMPLATE(BM_PointInAreaLocator, SimplePointInAreaLocator)->ArgsProduct({nPtsRange, nTestsRange});

BENCHMARK_MAIN();