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

Unified Diff: base/trace_event/memory_usage_estimator.h

Issue 2977783002: [tracing] Optimize StackFrameDeduplicator. (Closed)
Patch Set: Don't use ASSERT_EQ on deque iterators (see goo.gl/9gkBf7) Created 3 years, 5 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 | « base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_usage_estimator.h
diff --git a/base/trace_event/memory_usage_estimator.h b/base/trace_event/memory_usage_estimator.h
index 174429fa975a54b5a804bff9792448c5fbe3dfb6..90c94aba931f445f402809a9d1f73623f8952712 100644
--- a/base/trace_event/memory_usage_estimator.h
+++ b/base/trace_event/memory_usage_estimator.h
@@ -22,6 +22,8 @@
#include <vector>
#include "base/base_export.h"
+#include "base/containers/flat_map.h"
+#include "base/containers/flat_set.h"
#include "base/containers/linked_list.h"
#include "base/strings/string16.h"
@@ -150,6 +152,12 @@ size_t EstimateMemoryUsage(const std::priority_queue<T, C>& queue);
template <class T, class C>
size_t EstimateMemoryUsage(const std::stack<T, C>& stack);
+template <class T, class C>
+size_t EstimateMemoryUsage(const base::flat_set<T, C>& set);
+
+template <class K, class V, class C>
+size_t EstimateMemoryUsage(const base::flat_map<K, V, C>& map);
+
// TODO(dskiba):
// std::forward_list
@@ -542,6 +550,20 @@ size_t EstimateMemoryUsage(const std::stack<T, C>& stack) {
return EstimateMemoryUsage(internal::GetUnderlyingContainer(stack));
}
+// Flat containers
+
+template <class T, class C>
+size_t EstimateMemoryUsage(const base::flat_set<T, C>& set) {
+ using value_type = typename base::flat_set<T, C>::value_type;
+ return sizeof(value_type) * set.capacity() + EstimateIterableMemoryUsage(set);
+}
+
+template <class K, class V, class C>
+size_t EstimateMemoryUsage(const base::flat_map<K, V, C>& map) {
+ using value_type = typename base::flat_map<K, V, C>::value_type;
+ return sizeof(value_type) * map.capacity() + EstimateIterableMemoryUsage(map);
+}
+
} // namespace trace_event
} // namespace base
« no previous file with comments | « base/trace_event/heap_profiler_stack_frame_deduplicator_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698