summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-02 17:50:30 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-03 18:23:40 +0300
commit0461e08cf760b6cabffb93c7cd71c385b3ecb39c (patch)
tree0374c35bfdb64e09688328d2093e633f295966ac
parent747524778273b483af9f7b247d0756b524b82b71 (diff)
downloadqtlocation-mapboxgl-0461e08cf760b6cabffb93c7cd71c385b3ecb39c.tar.gz
[core][benchmark] Add API_renderStill_multiple_sources benchmark
-rw-r--r--benchmark/api/render.benchmark.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp
index 305ae8ce79..f192e7d3a3 100644
--- a/benchmark/api/render.benchmark.cpp
+++ b/benchmark/api/render.benchmark.cpp
@@ -1,18 +1,22 @@
#include <benchmark/benchmark.h>
+#include <mbgl/gfx/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_observer.hpp>
#include <mbgl/map/map_options.hpp>
-#include <mbgl/gfx/headless_frontend.hpp>
#include <mbgl/renderer/renderer.hpp>
-#include <mbgl/style/style.hpp>
-#include <mbgl/style/image.hpp>
-#include <mbgl/storage/resource_options.hpp>
#include <mbgl/storage/network_status.hpp>
+#include <mbgl/storage/resource_options.hpp>
+#include <mbgl/style/image.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/sources/geojson_source.hpp>
+#include <mbgl/style/style.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
+#include <sstream>
+
using namespace mbgl;
namespace {
@@ -94,7 +98,39 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
}
}
+static void API_renderStill_multiple_sources(::benchmark::State& state) {
+ using namespace mbgl::style;
+ RenderBenchmark bench;
+ HeadlessFrontend frontend{size, pixelRatio};
+ Map map{frontend,
+ MapObserver::nullObserver(),
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
+ ResourceOptions().withCachePath(cachePath).withAccessToken("foobar")};
+ prepare(map);
+ auto& style = map.getStyle();
+ const int kSourcesCount = 50;
+ const int kLayersCount = 50;
+ for (int i = 0; i < kSourcesCount; ++i) {
+ std::ostringstream sourceOss;
+ sourceOss << "GeoJSONSource" << i;
+ std::string sourceId{sourceOss.str()};
+ auto source = std::make_unique<GeoJSONSource>(sourceId);
+ style.addSource(std::move(source));
+ for (int j = 0; j < kLayersCount; ++j) {
+ std::ostringstream layerOss;
+ layerOss << sourceId << '#' << j;
+ auto layer = std::make_unique<SymbolLayer>(layerOss.str(), sourceId);
+ style.addLayer(std::move(layer));
+ }
+ }
+
+ while (state.KeepRunning()) {
+ frontend.render(map);
+ }
+}
+
BENCHMARK(API_renderStill_reuse_map);
BENCHMARK(API_renderStill_reuse_map_formatted_labels);
BENCHMARK(API_renderStill_reuse_map_switch_styles);
BENCHMARK(API_renderStill_recreate_map);
+BENCHMARK(API_renderStill_multiple_sources);