summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-27 11:38:17 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-27 11:38:17 +0300
commit455a02466152f6fe3d2b65e2b0271519d789aab9 (patch)
treeb27d97cf04e0ceaf92244b26c4f6433afb241717
parenta7745b3383683d59f27ff0cf7a820becbdb87f1a (diff)
downloadqtlocation-mapboxgl-upstream/mikhail_memory_metrics.tar.gz
[test runner] Use allocation peak values for memory metricsupstream/mikhail_memory_metrics
-rw-r--r--render-test/allocation_index.cpp8
-rw-r--r--render-test/allocation_index.hpp9
-rw-r--r--render-test/metadata.hpp6
-rw-r--r--render-test/parser.cpp2
-rw-r--r--render-test/runner.cpp10
5 files changed, 25 insertions, 10 deletions
diff --git a/render-test/allocation_index.cpp b/render-test/allocation_index.cpp
index 12ac7b5b77..144c18ddd5 100644
--- a/render-test/allocation_index.cpp
+++ b/render-test/allocation_index.cpp
@@ -9,6 +9,7 @@
namespace {
std::atomic_size_t indexedMemorySize{0};
+std::atomic_size_t indexedMemoryPeak{0};
std::atomic_size_t allocationsCount{0};
std::unordered_map<void*, size_t> memoryIndex;
std::atomic_bool suppresIndexing{false};
@@ -30,6 +31,7 @@ void addToIndex(std::size_t sz, void* ptr) {
FlagGuard flk(suppresIndexing);
allocationsCount++;
indexedMemorySize += sz;
+ if (indexedMemoryPeak < indexedMemorySize) indexedMemoryPeak = size_t(indexedMemorySize);
memoryIndex[ptr] = sz;
}
@@ -67,6 +69,7 @@ void AllocationIndex::reset() {
memoryIndex.clear();
indexedMemorySize = 0;
allocationsCount = 0;
+ indexedMemoryPeak = 0;
}
// static
@@ -91,3 +94,8 @@ size_t AllocationIndex::getAllocatedSize() {
size_t AllocationIndex::getAllocationsCount() {
return allocationsCount;
}
+
+// static
+size_t AllocationIndex::getAllocatedSizePeak() {
+ return indexedMemoryPeak;
+}
diff --git a/render-test/allocation_index.hpp b/render-test/allocation_index.hpp
index 42c8f3d4e7..71da441c1f 100644
--- a/render-test/allocation_index.hpp
+++ b/render-test/allocation_index.hpp
@@ -43,4 +43,11 @@ public:
* @return size_t
*/
static size_t getAllocationsCount();
-}; \ No newline at end of file
+
+ /**
+ * @brief Returns the maximum size (in bytes) of the allocated data in the index, since last `reset()` call.
+ *
+ * @return size_t
+ */
+ static size_t getAllocatedSizePeak();
+};
diff --git a/render-test/metadata.hpp b/render-test/metadata.hpp
index 5e96301e4d..d23a0fb296 100644
--- a/render-test/metadata.hpp
+++ b/render-test/metadata.hpp
@@ -31,11 +31,11 @@ struct TestPaths {
struct MemoryProbe {
MemoryProbe() = default;
- MemoryProbe(size_t size_, size_t allocations_)
- : size(size_)
+ MemoryProbe(size_t peak_, size_t allocations_)
+ : peak(peak_)
, allocations(allocations_) {}
- size_t size;
+ size_t peak;
size_t allocations;
};
diff --git a/render-test/parser.cpp b/render-test/parser.cpp
index 581529a745..4598ba3786 100644
--- a/render-test/parser.cpp
+++ b/render-test/parser.cpp
@@ -199,7 +199,7 @@ std::string serializeMetrics(const TestMetrics& metrics) {
assert(!memoryProbe.first.empty());
writer.StartArray();
writer.String(memoryProbe.first.c_str());
- writer.Uint64(memoryProbe.second.size);
+ writer.Uint64(memoryProbe.second.peak);
writer.Uint64(memoryProbe.second.allocations);
writer.EndArray();
}
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index e325c82b1d..54660979cf 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -131,10 +131,10 @@ bool TestRunner::checkResults(mbgl::PremultipliedImage&& actualImage, TestMetada
metadata.errorMessage = "Failed to find memory probe: " + expected.first;
return false;
}
- if (actual->second.size > expected.second.size) {
+ if (actual->second.peak > expected.second.peak) {
std::stringstream ss;
- ss << "Allocated size at memory probe \" " << expected.first << "\" is "
- << actual->second.size << " bytes, expected is " << expected.second.size << " bytes.";
+ ss << "Allocated memory peak size at probe \"" << expected.first << "\" is "
+ << actual->second.peak << " bytes, expected is " << expected.second.peak << " bytes.";
metadata.errorMessage = ss.str();
return false;
@@ -142,7 +142,7 @@ bool TestRunner::checkResults(mbgl::PremultipliedImage&& actualImage, TestMetada
if (actual->second.allocations > expected.second.allocations) {
std::stringstream ss;
- ss << "Number of allocations at memory probe \" " << expected.first << "\" is "
+ ss << "Number of allocations at probe \"" << expected.first << "\" is "
<< actual->second.allocations << ", expected is " << expected.second.allocations << ".";
metadata.errorMessage = ss.str();
@@ -447,7 +447,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
metadata.metrics.memory.emplace(std::piecewise_construct,
std::forward_as_tuple(std::move(mark)),
- std::forward_as_tuple(AllocationIndex::getAllocatedSize(), AllocationIndex::getAllocationsCount()));
+ std::forward_as_tuple(AllocationIndex::getAllocatedSizePeak(), AllocationIndex::getAllocationsCount()));
// probeMemoryEnd
} else if (operationArray[0].GetString() == memoryProbeEndOp) {
assert(AllocationIndex::isActive());