summaryrefslogtreecommitdiff
path: root/render-test/runner.cpp
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-11 10:43:02 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-10-21 16:10:45 +0300
commit9adc78134c261d5e236faac3b537e1cfd937880a (patch)
treeb9a12b9fe8ddc5e828e588efc04187148e042e77 /render-test/runner.cpp
parentf41f274ca16032da8c41186b2181f0c800d777df (diff)
downloadqtlocation-mapboxgl-9adc78134c261d5e236faac3b537e1cfd937880a.tar.gz
[test runner] Threshold for memory metrics
Diffstat (limited to 'render-test/runner.cpp')
-rw-r--r--render-test/runner.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index 810806d231..925599dfb8 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -276,19 +276,23 @@ bool TestRunner::checkRenderTestResults(mbgl::PremultipliedImage&& actualImage,
metadata.errorMessage = "Failed to find memory probe: " + expected.first;
return false;
}
- if (actual->second.peak > expected.second.peak) {
+ bool passed{false};
+ float delta{0.0f};
+ std::tie(passed, delta) = MemoryProbe::checkPeak(expected.second, actual->second);
+ if (!passed) {
std::stringstream ss;
- ss << "Allocated memory peak size at probe \"" << expected.first << "\" is "
- << actual->second.peak << " bytes, expected is " << expected.second.peak << " bytes.";
+ ss << "Allocated memory peak size at probe \"" << expected.first << "\" is " << actual->second.peak
+ << " bytes, expected is " << expected.second.peak << "±" << delta << " bytes.";
metadata.errorMessage = ss.str();
return false;
}
- if (actual->second.allocations > expected.second.allocations) {
+ std::tie(passed, delta) = MemoryProbe::checkAllocations(expected.second, actual->second);
+ if (!passed) {
std::stringstream ss;
- ss << "Number of allocations at probe \"" << expected.first << "\" is "
- << actual->second.allocations << ", expected is " << expected.second.allocations << ".";
+ ss << "Number of allocations at probe \"" << expected.first << "\" is " << actual->second.allocations
+ << ", expected is " << expected.second.allocations << "±" << delta << " allocations.";
metadata.errorMessage = ss.str();
return false;
@@ -644,9 +648,15 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
assert(operationArray[1].IsString());
std::string mark = std::string(operationArray[1].GetString(), operationArray[1].GetStringLength());
- metadata.metrics.memory.emplace(std::piecewise_construct,
- std::forward_as_tuple(std::move(mark)),
- std::forward_as_tuple(AllocationIndex::getAllocatedSizePeak(), AllocationIndex::getAllocationsCount()));
+ auto emplaced = metadata.metrics.memory.emplace(
+ std::piecewise_construct,
+ std::forward_as_tuple(std::move(mark)),
+ std::forward_as_tuple(AllocationIndex::getAllocatedSizePeak(), AllocationIndex::getAllocationsCount()));
+ assert(emplaced.second);
+ if (operationArray.Size() >= 3u) {
+ assert(operationArray[2].IsNumber());
+ emplaced.first->second.tolerance = float(operationArray[2].GetDouble());
+ }
} else if (operationArray[0].GetString() == memoryProbeEndOp) {
// probeMemoryEnd
assert(AllocationIndex::isActive());