OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
6 #define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 6 #define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // Specialized profiling functions for commonly used object types. | 37 // Specialized profiling functions for commonly used object types. |
38 void AddString(const std::string& str); | 38 void AddString(const std::string& str); |
39 void AddValue(const Value& value); | 39 void AddValue(const Value& value); |
40 void AddRefCountedString(const RefCountedString& str); | 40 void AddRefCountedString(const RefCountedString& str); |
41 | 41 |
42 // Call this after all the Add* methods above to account the memory used by | 42 // Call this after all the Add* methods above to account the memory used by |
43 // this TraceEventMemoryOverhead instance itself. | 43 // this TraceEventMemoryOverhead instance itself. |
44 void AddSelf(); | 44 void AddSelf(); |
45 | 45 |
| 46 // Retrieves the count, that is, the count of Add*(|object_type|, ...) calls. |
| 47 size_t GetCount(const char* object_type) const; |
| 48 |
46 // Adds up and merges all the values from |other| to this instance. | 49 // Adds up and merges all the values from |other| to this instance. |
47 void Update(const TraceEventMemoryOverhead& other); | 50 void Update(const TraceEventMemoryOverhead& other); |
48 | 51 |
49 void DumpInto(const char* base_name, ProcessMemoryDump* pmd) const; | 52 void DumpInto(const char* base_name, ProcessMemoryDump* pmd) const; |
50 | 53 |
51 private: | 54 private: |
52 struct ObjectCountAndSize { | 55 struct ObjectCountAndSize { |
53 size_t count; | 56 size_t count; |
54 size_t allocated_size_in_bytes; | 57 size_t allocated_size_in_bytes; |
55 size_t resident_size_in_bytes; | 58 size_t resident_size_in_bytes; |
56 }; | 59 }; |
57 using map_type = SmallMap<hash_map<const char*, ObjectCountAndSize>, 16>; | 60 using map_type = SmallMap<hash_map<const char*, ObjectCountAndSize>, 16>; |
58 map_type allocated_objects_; | 61 map_type allocated_objects_; |
59 | 62 |
60 void AddOrCreateInternal(const char* object_type, | 63 void AddOrCreateInternal(const char* object_type, |
61 size_t count, | 64 size_t count, |
62 size_t allocated_size_in_bytes, | 65 size_t allocated_size_in_bytes, |
63 size_t resident_size_in_bytes); | 66 size_t resident_size_in_bytes); |
64 | 67 |
65 DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead); | 68 DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead); |
66 }; | 69 }; |
67 | 70 |
68 } // namespace trace_event | 71 } // namespace trace_event |
69 } // namespace base | 72 } // namespace base |
70 | 73 |
71 #endif // BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 74 #endif // BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
OLD | NEW |