Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3149)

Unified Diff: courgette/memory_allocator.cc

Issue 2883773002: [Courgette Experiment] Track and print TempMapping total and peak allocation to measure Courgette d…
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/memory_allocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/memory_allocator.cc
diff --git a/courgette/memory_allocator.cc b/courgette/memory_allocator.cc
index e83a293ae6e474d40b09e3abf03dded377ae89e2..0325b28233b78d94ba86802e6e4193bb68412c3b 100644
--- a/courgette/memory_allocator.cc
+++ b/courgette/memory_allocator.cc
@@ -7,7 +7,7 @@
#include <stddef.h>
#include <stdint.h>
-#include <map>
+#include <algorithm>
#include "base/files/file_util.h"
#include "base/strings/stringprintf.h"
@@ -83,10 +83,15 @@ void* FileMapping::view() const {
// TempMapping
+long long TempMapping::alloc_cur = 0;
+long long TempMapping::alloc_sum = 0;
+long long TempMapping::alloc_max = 0;
+
TempMapping::TempMapping() {
}
TempMapping::~TempMapping() {
+ alloc_cur -= size_;
}
bool TempMapping::Initialize(size_t size) {
@@ -107,6 +112,11 @@ bool TempMapping::Initialize(size_t size) {
TempMapping** write = reinterpret_cast<TempMapping**>(mapping_.view());
write[0] = this;
+ size_ = size;
+ alloc_cur += size_;
+ alloc_sum += size_;
+ alloc_max = std::max(alloc_max, alloc_cur);
+
return true;
}
« no previous file with comments | « courgette/memory_allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698