summaryrefslogtreecommitdiff
path: root/benchmark/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-05-20 14:23:39 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-05-21 01:04:01 +0300
commit88ef7d89c46b4c4e6e8ad84a5c8e9f410ef6d3cb (patch)
treeeebed2cf856394181e164c15b7421f22a0fc8c99 /benchmark/storage
parent19f5686eb21c9499e5cc34d217308aa99f31c666 (diff)
downloadqtlocation-mapboxgl-88ef7d89c46b4c4e6e8ad84a5c8e9f410ef6d3cb.tar.gz
[benchmark] Add benchmark for tile invalidation
Diffstat (limited to 'benchmark/storage')
-rw-r--r--benchmark/storage/offline_database.benchmark.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/benchmark/storage/offline_database.benchmark.cpp b/benchmark/storage/offline_database.benchmark.cpp
new file mode 100644
index 0000000000..2adce537f0
--- /dev/null
+++ b/benchmark/storage/offline_database.benchmark.cpp
@@ -0,0 +1,54 @@
+#include <benchmark/benchmark.h>
+
+#include <mbgl/storage/offline_database.hpp>
+#include <mbgl/storage/resource.hpp>
+#include <mbgl/storage/response.hpp>
+#include <mbgl/storage/sqlite3.hpp>
+#include <mbgl/util/string.hpp>
+
+class OfflineDatabase : public benchmark::Fixture {
+public:
+ void SetUp(const ::benchmark::State&) override {
+ using namespace mbgl;
+ using namespace std::chrono_literals;
+
+ const unsigned tileCount = 10000;
+ db.setOfflineMapboxTileCountLimit(tileCount * 2);
+
+ Response response;
+ response.noContent = true;
+ response.mustRevalidate = false;
+ response.expires = util::now() + 1h;
+
+ for (unsigned i = 0; i < tileCount; ++i) {
+ const Resource ambient = Resource::tile("mapbox://tile_ambient" + util::toString(i), 1, 0, 0, 0, Tileset::Scheme::XYZ);
+ db.put(ambient, response);
+ }
+
+ OfflineTilePyramidRegionDefinition definition{ "mapbox://style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0, true };
+ OfflineRegionMetadata metadata{{ 1, 2, 3 }};
+
+ auto region = db.createRegion(definition, metadata);
+ regionID = region->getID();
+
+ for (unsigned i = 0; i < tileCount; ++i) {
+ const Resource offline = Resource::tile("mapbox://tile_offline_region" + util::toString(i), 1.0, 0, 0, 0, Tileset::Scheme::XYZ);
+ db.putRegionResource(regionID, offline, response);
+ }
+ }
+
+ mbgl::OfflineDatabase db{":memory:"};
+ int64_t regionID;
+};
+
+BENCHMARK_F(OfflineDatabase, InvalidateRegion)(benchmark::State& state) {
+ for (auto _ : state) {
+ db.invalidateRegion(regionID);
+ }
+}
+
+BENCHMARK_F(OfflineDatabase, InvalidateTileCache)(benchmark::State& state) {
+ for (auto _ : state) {
+ db.invalidateTileCache();
+ }
+}