diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-21 18:36:43 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-22 18:54:48 +0200 |
commit | 03db58cdc1f1f31034863020f205f5c5696bfa8b (patch) | |
tree | e4201a14948d3772fbd4f8bcff6f7d38e2dfd27d /benchmark | |
parent | 2de2b0b068520a55170d23c86f349232b3e28ae7 (diff) | |
download | qtlocation-mapboxgl-03db58cdc1f1f31034863020f205f5c5696bfa8b.tar.gz |
[core] Replace shared_ptr with unique_ptr in {Map,Resource}Options
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/api/render.benchmark.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp index 0e7a3be322..b66c3f228c 100644 --- a/benchmark/api/render.benchmark.cpp +++ b/benchmark/api/render.benchmark.cpp @@ -18,6 +18,10 @@ using namespace mbgl; namespace { +static std::string cachePath { "benchmark/fixtures/api/cache.db" }; +constexpr double pixelRatio { 1.0 }; +constexpr Size size { 1000, 1000 }; + class RenderBenchmark { public: RenderBenchmark() { @@ -27,22 +31,23 @@ public: util::RunLoop loop; ThreadPool threadPool { 4 }; }; - + static void prepare(Map& map, optional<std::string> json = {}) { map.getStyle().loadJSON(json ? *json : util::read_file("benchmark/fixtures/api/style.json")); map.jumpTo(CameraOptions().withCenter(LatLng { 40.726989, -73.992857 }).withZoom(15.0)); // Manhattan - map.getStyle().addImage(std::make_unique<style::Image>("test-icon", - decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")), 1.0)); + + auto image = decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")); + map.getStyle().addImage(std::make_unique<style::Image>("test-icon", std::move(image), 1.0)); } - + } // end namespace static void API_renderStill_reuse_map(::benchmark::State& state) { RenderBenchmark bench; - HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.threadPool, + HeadlessFrontend frontend { size, pixelRatio, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), size, pixelRatio, bench.threadPool, MapOptions().withMapMode(MapMode::Static), - ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar") }; + ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") }; prepare(map); while (state.KeepRunning()) { @@ -52,10 +57,9 @@ static void API_renderStill_reuse_map(::benchmark::State& state) { static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state) { RenderBenchmark bench; - HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.threadPool, - MapOptions().withMapMode(MapMode::Static), - ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar") }; + HeadlessFrontend frontend { size, pixelRatio, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), size, pixelRatio, bench.threadPool, + MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") }; prepare(map, util::read_file("benchmark/fixtures/api/style_formatted_labels.json")); while (state.KeepRunning()) { @@ -65,11 +69,10 @@ static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) { RenderBenchmark bench; - HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.threadPool, - MapOptions().withMapMode(MapMode::Static), - ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar") }; - + HeadlessFrontend frontend { size, pixelRatio, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), size, pixelRatio, bench.threadPool, + MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") }; + while (state.KeepRunning()) { prepare(map, { "{}" }); frontend.render(map); @@ -80,11 +83,11 @@ static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) { static void API_renderStill_recreate_map(::benchmark::State& state) { RenderBenchmark bench; - auto mapOptions = MapOptions().withMapMode(MapMode::Static); - auto resourceOptions = ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar"); + while (state.KeepRunning()) { - HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.threadPool, mapOptions, resourceOptions }; + HeadlessFrontend frontend { size, pixelRatio, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), size, pixelRatio, bench.threadPool, + MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") }; prepare(map); frontend.render(map); } |