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

Unified Diff: base/trace_event/trace_event_memory_overhead.h

Issue 2857543002: tracing: Simplify TraceEventMemoryOverhead, use an enum insted of a map (Closed)
Patch Set: Fix compiler issues + omit empty values Created 3 years, 8 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_impl.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
index 0d5769bdcd3e7516abeed45cc679947614ce6c34..1587a3099f6adfc35fb5533e3b1852e122c18866 100644
--- a/base/trace_event/trace_event_memory_overhead.h
+++ b/base/trace_event/trace_event_memory_overhead.h
@@ -6,12 +6,11 @@
#define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_
#include <stddef.h>
+#include <stdint.h>
#include <unordered_map>
#include "base/base_export.h"
-#include "base/containers/hash_tables.h"
-#include "base/containers/small_map.h"
#include "base/macros.h"
namespace base {
@@ -26,18 +25,35 @@ class ProcessMemoryDump;
// Used to estimate the memory overhead of the tracing infrastructure.
class BASE_EXPORT TraceEventMemoryOverhead {
public:
+ enum ObjectType : uint32_t {
+ kOther = 0,
+ kTraceBuffer,
+ kTraceBufferChunk,
+ kTraceEvent,
+ kUnusedTraceEvent,
+ kTracedValue,
+ kConvertableToTraceFormat,
+ kHeapProfilerAllocationRegister,
+ kHeapProfilerTypeNameDeduplicator,
+ kHeapProfilerStackFrameDeduplicator,
+ kStdString,
+ kBaseValue,
+ kTraceEventMemoryOverhead,
+ kLast
+ };
+
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,
+ void Add(ObjectType 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);
+ void Add(ObjectType object_type, size_t allocated_size_in_bytes);
// Specialized profiling functions for commonly used object types.
void AddString(const std::string& str);
@@ -49,7 +65,7 @@ class BASE_EXPORT TraceEventMemoryOverhead {
void AddSelf();
// Retrieves the count, that is, the count of Add*(|object_type|, ...) calls.
- size_t GetCount(const char* object_type) const;
+ size_t GetCount(ObjectType object_type) const;
// Adds up and merges all the values from |other| to this instance.
void Update(const TraceEventMemoryOverhead& other);
@@ -62,14 +78,12 @@ class BASE_EXPORT TraceEventMemoryOverhead {
size_t allocated_size_in_bytes;
size_t resident_size_in_bytes;
};
- using map_type =
- small_map<std::unordered_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);
+ ObjectCountAndSize allocated_objects_[ObjectType::kLast];
+
+ void AddInternal(ObjectType object_type,
+ size_t count,
+ size_t allocated_size_in_bytes,
+ size_t resident_size_in_bytes);
DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead);
};
« no previous file with comments | « base/trace_event/trace_event_impl.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