summaryrefslogtreecommitdiff
path: root/render-test/parser.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-10-09 16:12:02 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-10-10 19:54:51 +0300
commita9f06f3b527601fc0d7a1c254af414e7a313eef0 (patch)
tree6948a3dbc0553f18566c90c7c04d300896d80d73 /render-test/parser.cpp
parent026e15fe3d6dae0c3f11775d19dcfc13743ff1c0 (diff)
downloadqtlocation-mapboxgl-a9f06f3b527601fc0d7a1c254af414e7a313eef0.tar.gz
[render-test] Add instruction for verifying file size
For a given absolute or relative path, measure the size of the file. This is useful for measuring if the cache has increased as expected after moving a camera or decreased after cleaning up. In a more hackish manner, could be used for collecting binary size statistics of shared libraries.
Diffstat (limited to 'render-test/parser.cpp')
-rw-r--r--render-test/parser.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/render-test/parser.cpp b/render-test/parser.cpp
index e9df704941..613fc566ea 100644
--- a/render-test/parser.cpp
+++ b/render-test/parser.cpp
@@ -273,6 +273,21 @@ std::string serializeMetrics(const TestMetrics& metrics) {
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
writer.StartObject();
+
+ // Start fileSize section.
+ writer.Key("fileSize");
+ writer.StartArray();
+ for (const auto& fileSizeProbe : metrics.fileSize) {
+ assert(!fileSizeProbe.first.empty());
+ writer.StartArray();
+ writer.String(fileSizeProbe.first.c_str());
+ writer.String(fileSizeProbe.second.path);
+ writer.Uint64(fileSizeProbe.second.size);
+ writer.EndArray();
+ }
+ // End fileSize section.
+ writer.EndArray();
+
// Start memory section.
writer.Key("memory");
writer.StartArray();
@@ -286,6 +301,7 @@ std::string serializeMetrics(const TestMetrics& metrics) {
}
// End memory section.
writer.EndArray();
+
writer.EndObject();
return s.GetString();
@@ -439,6 +455,29 @@ TestMetrics readExpectedMetrics(const mbgl::filesystem::path& path) {
}
const auto& document = maybeJson.get<mbgl::JSDocument>();
+
+ if (document.HasMember("fileSize")) {
+ const mbgl::JSValue& fileSizeValue = document["fileSize"];
+ assert(fileSizeValue.IsArray());
+ for (auto& probeValue : fileSizeValue.GetArray()) {
+ assert(probeValue.IsArray());
+ assert(probeValue.Size() >= 3u);
+ assert(probeValue[0].IsString());
+ assert(probeValue[1].IsString());
+ assert(probeValue[2].IsNumber());
+
+ std::string mark{probeValue[0].GetString(), probeValue[0].GetStringLength()};
+ assert(!mark.empty());
+
+ std::string filePath{probeValue[1].GetString(), probeValue[1].GetStringLength()};
+ assert(!filePath.empty());
+
+ result.fileSize.emplace(std::piecewise_construct,
+ std::forward_as_tuple(std::move(mark)),
+ std::forward_as_tuple(std::move(filePath), probeValue[2].GetUint64()));
+ }
+ }
+
if (document.HasMember("memory")) {
const mbgl::JSValue& memoryValue = document["memory"];
assert(memoryValue.IsArray());