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

Unified Diff: base/trace_event/trace_event_memory_overhead.h

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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/trace_event_memory.cc ('k') | base/trace_event/trace_event_memory_overhead.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/trace_event_memory_overhead.h
diff --git a/base/trace_event/trace_event_memory_overhead.h b/base/trace_event/trace_event_memory_overhead.h
new file mode 100644
index 0000000000000000000000000000000000000000..8ecf12dc969eb4f0dc26516061450cff5d229509
--- /dev/null
+++ b/base/trace_event/trace_event_memory_overhead.h
@@ -0,0 +1,71 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_
+#define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_
+
+#include "base/base_export.h"
+#include "base/containers/hash_tables.h"
+#include "base/containers/small_map.h"
+
+namespace base {
+
+class RefCountedString;
+class Value;
+
+namespace trace_event {
+
+class ProcessMemoryDump;
+
+// Used to estimate the memory overhead of the tracing infrastructure.
+class BASE_EXPORT TraceEventMemoryOverhead {
+ public:
+ TraceEventMemoryOverhead();
+ ~TraceEventMemoryOverhead();
+
+ // Use this method to account the overhead of an object for which an estimate
+ // is known for both the allocated and resident memory.
+ void Add(const char* object_type,
+ size_t allocated_size_in_bytes,
+ size_t resident_size_in_bytes);
+
+ // Similar to Add() above, but assumes that
+ // |resident_size_in_bytes| == |allocated_size_in_bytes|.
+ void Add(const char* object_type, size_t allocated_size_in_bytes);
+
+ // Specialized profiling functions for commonly used object types.
+ void AddString(const std::string& str);
+ void AddValue(const Value& value);
+ void AddRefCountedString(const RefCountedString& str);
+
+ // Call this after all the Add* methods above to account the memory used by
+ // this TraceEventMemoryOverhead instance itself.
+ void AddSelf();
+
+ // Adds up and merges all the values from |other| to this instance.
+ void Update(const TraceEventMemoryOverhead& other);
+
+ void DumpInto(const char* base_name, ProcessMemoryDump* pmd) const;
+
+ private:
+ struct ObjectCountAndSize {
+ size_t count;
+ size_t allocated_size_in_bytes;
+ size_t resident_size_in_bytes;
+ };
+ using map_type = SmallMap<hash_map<const char*, ObjectCountAndSize>, 16>;
+ map_type allocated_objects_;
+
+ void AddOrCreateInternal(const char* object_type,
+ size_t count,
+ size_t allocated_size_in_bytes,
+ size_t resident_size_in_bytes);
+
+ DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead);
+};
+
+} // namespace trace_event
+} // namespace base
+
+#endif // BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_
« no previous file with comments | « base/trace_event/trace_event_memory.cc ('k') | base/trace_event/trace_event_memory_overhead.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698