summaryrefslogtreecommitdiff
path: root/render-test/runner.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-11-28 18:12:13 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-11-28 19:18:17 +0200
commit8c9b038af3723252014362557bba9e9c43780ff3 (patch)
treeb768eb51c949dd09823c21ca81de4b4e1fc113cd /render-test/runner.cpp
parentb5794730b5cfba58be0aa63070718cde662bb538 (diff)
downloadqtlocation-mapboxgl-8c9b038af3723252014362557bba9e9c43780ff3.tar.gz
[render-test] Add support for measuring compressed file size
Useful because for platform such as Android, we want to measure the size of the library inside the APK, which is usually compressed.
Diffstat (limited to 'render-test/runner.cpp')
-rw-r--r--render-test/runner.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index 05ba089d81..24bc6668d7 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -12,6 +12,7 @@
#include <mbgl/style/rapidjson_conversion.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/compression.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
@@ -837,12 +838,25 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata, R
float tolerance = operationArray[3].GetDouble();
mbgl::filesystem::path filePath(path);
+ bool compressed = false;
+ if (operationArray.Size() == 5) {
+ assert(operationArray[4].IsString());
+ assert(std::string(operationArray[4].GetString(), operationArray[4].GetStringLength()) == "compressed");
+ compressed = true;
+ }
+
if (!filePath.is_absolute()) {
filePath = metadata.paths.defaultExpectations() / filePath;
}
if (mbgl::filesystem::exists(filePath)) {
- auto size = mbgl::filesystem::file_size(filePath);
+ size_t size = 0;
+ if (compressed) {
+ size = mbgl::util::compress(*mbgl::util::readFile(filePath)).size();
+ } else {
+ size = mbgl::filesystem::file_size(filePath);
+ }
+
metadata.metrics.fileSize.emplace(std::piecewise_construct,
std::forward_as_tuple(std::move(mark)),
std::forward_as_tuple(std::move(path), size, tolerance));