summaryrefslogtreecommitdiff
path: root/benchmark/parse/vector_tile.benchmark.cpp
blob: fab22ae3808a279520c66a7163addec07baa1d5f (plain)
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
#include <benchmark/benchmark.h>

#include <mbgl/tile/vector_tile_data.hpp>
#include <mbgl/util/io.hpp>

using namespace mbgl;

static void Parse_VectorTile(benchmark::State& state) {
    auto data = util::readFile("test/fixtures/api/assets/streets/10-163-395.vector.pbf");

    while (state.KeepRunning()) {
        std::size_t length = 0;
        VectorTileData tile(data);
        for (const auto& name : tile.layerNames()) {
            if (auto layer = tile.getLayer(name)) {
                const std::size_t count = layer->featureCount();
                for (std::size_t i = 0; i < count; i++) {
                    if (auto feature = layer->getFeature(i)) {
                        length += feature->getGeometries().size();
                        length += feature->getProperties().size();
                    }
                }
            }
        }
    }
}

BENCHMARK(Parse_VectorTile);