summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-14 19:47:05 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-06-18 16:26:51 +0300
commitffecb4d6d6a439fb6b6e7aa000fafb5cd169b02a (patch)
tree12883d2819a21b8c12cfde16a3479369158f8340 /benchmark
parent1977934bdb2385c2ac9051a6f23817cbdf12348c (diff)
downloadqtlocation-mapboxgl-ffecb4d6d6a439fb6b6e7aa000fafb5cd169b02a.tar.gz
[benchmark] Add benchmark tests for resizing the database
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/storage/offline_database.benchmark.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/benchmark/storage/offline_database.benchmark.cpp b/benchmark/storage/offline_database.benchmark.cpp
index be17201f33..afdf6db4fc 100644
--- a/benchmark/storage/offline_database.benchmark.cpp
+++ b/benchmark/storage/offline_database.benchmark.cpp
@@ -5,6 +5,7 @@
#include <mbgl/storage/response.hpp>
#include <mbgl/storage/sqlite3.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/logging.hpp>
#include <random>
@@ -129,3 +130,67 @@ BENCHMARK_F(OfflineDatabase, GetTile)(benchmark::State& state) {
assert(res != nullopt);
}
}
+
+BENCHMARK_F(OfflineDatabase, AddTilesToFullDatabase)(benchmark::State& state) {
+ using namespace mbgl;
+
+ Log::setObserver(std::make_unique<Log::NullObserver>());
+ db.setMaximumAmbientCacheSize(50 * 1024 * 5);
+
+ while (state.KeepRunning()) {
+ const Resource ambient = Resource::tile("mapbox://AddTilesToFullDatabase" +
+ util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
+ db.put(ambient, response);
+ }
+
+ Log::removeObserver();
+}
+
+BENCHMARK_F(OfflineDatabase, AddTilesToDisabledDatabase)(benchmark::State& state) {
+ using namespace mbgl;
+
+ auto regions = db.listRegions().value();
+ if (!regions.empty()) {
+ db.deleteRegion(std::move(regions[0]));
+ }
+
+ // Disables the ambient cache.
+ db.setMaximumAmbientCacheSize(0);
+
+ while (state.KeepRunning()) {
+ const Resource ambient = Resource::tile("mapbox://AddTilesToFullDatabase" +
+ util::toString(state.iterations()), 1, 0, 0, 0, Tileset::Scheme::XYZ);
+ db.put(ambient, response);
+ }
+}
+
+BENCHMARK_F(OfflineDatabase, GetTileFromDisabledDatabase)(benchmark::State& state) {
+ using namespace mbgl;
+
+ auto regions = db.listRegions().value();
+ if (!regions.empty()) {
+ db.deleteRegion(std::move(regions[0]));
+ }
+
+ // Disables the ambient cache.
+ db.setMaximumAmbientCacheSize(0);
+
+ while (state.KeepRunning()) {
+ auto res = db.get(Resource::tile("mapbox://tile_ambient", 1, 0, 0, 0, Tileset::Scheme::XYZ));
+ assert(res == nullopt);
+ }
+}
+
+BENCHMARK_F(OfflineDatabase, ResizeDatabase)(benchmark::State& state) {
+ uint64_t size = 25 * 1024 * 1024;
+
+ while (state.KeepRunning()) {
+ db.setMaximumAmbientCacheSize(size);
+
+ size -= response.data->size();
+
+ if (size < response.data->size()) {
+ size = 25 * 1024 * 1024;
+ }
+ }
+}