diff options
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/api/query.benchmark.cpp | 5 | ||||
-rw-r--r-- | benchmark/parse/vector_tile.benchmark.cpp | 28 |
2 files changed, 31 insertions, 2 deletions
diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp index faf6c4fbe4..05732e0e9a 100644 --- a/benchmark/api/query.benchmark.cpp +++ b/benchmark/api/query.benchmark.cpp @@ -6,6 +6,7 @@ #include <mbgl/gl/headless_backend.hpp> #include <mbgl/gl/offscreen_view.hpp> #include <mbgl/util/default_thread_pool.hpp> +#include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/storage/default_file_source.hpp> #include <mbgl/storage/network_status.hpp> @@ -23,9 +24,9 @@ public: NetworkStatus::Set(NetworkStatus::Status::Offline); fileSource.setAccessToken("foobar"); - map.setStyleJSON(util::read_file("benchmark/fixtures/api/query_style.json")); + map.getStyle().loadJSON(util::read_file("benchmark/fixtures/api/query_style.json")); map.setLatLngZoom({ 40.726989, -73.992857 }, 15); // Manhattan - map.addImage("test-icon", std::make_unique<style::Image>( + map.getStyle().addImage(std::make_unique<style::Image>("test-icon", decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")), 1.0)); mbgl::benchmark::render(map, view); 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); |