diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-06-21 11:03:00 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-06-21 17:18:08 -0700 |
commit | 4bfc5592239d96d6d352ddbbb906dde0ea4012be (patch) | |
tree | 69b21df248c309a83cdc837558a571e95f830107 /benchmark | |
parent | 6ec406b6affc423a366e74cfe0437a621bf11b81 (diff) | |
download | qtlocation-mapboxgl-4bfc5592239d96d6d352ddbbb906dde0ea4012be.tar.gz |
[core] add benchmark for vector tile parsing
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/parse/vector_tile.benchmark.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/benchmark/parse/vector_tile.benchmark.cpp b/benchmark/parse/vector_tile.benchmark.cpp new file mode 100644 index 0000000000..24623dbda7 --- /dev/null +++ b/benchmark/parse/vector_tile.benchmark.cpp @@ -0,0 +1,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 = std::make_shared<std::string>(util::read_file("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); |