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

Side by Side Diff: base/trace_event/heap_profiler_allocation_register.cc

Issue 2857543002: tracing: Simplify TraceEventMemoryOverhead, use an enum insted of a map (Closed)
Patch Set: Fix compiler issues + omit empty values 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_stack_frame_deduplicator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/trace_event/heap_profiler_allocation_register.h" 5 #include "base/trace_event/heap_profiler_allocation_register.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/trace_event/trace_event_memory_overhead.h" 10 #include "base/trace_event/trace_event_memory_overhead.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 AllocationRegister::ConstIterator AllocationRegister::end() const { 151 AllocationRegister::ConstIterator AllocationRegister::end() const {
152 return ConstIterator(*this, AllocationMap::kInvalidKVIndex); 152 return ConstIterator(*this, AllocationMap::kInvalidKVIndex);
153 } 153 }
154 154
155 void AllocationRegister::EstimateTraceMemoryOverhead( 155 void AllocationRegister::EstimateTraceMemoryOverhead(
156 TraceEventMemoryOverhead* overhead) const { 156 TraceEventMemoryOverhead* overhead) const {
157 size_t allocated = sizeof(AllocationRegister); 157 size_t allocated = sizeof(AllocationRegister);
158 size_t resident = sizeof(AllocationRegister) + 158 size_t resident = sizeof(AllocationRegister) +
159 allocations_.EstimateUsedMemory() + 159 allocations_.EstimateUsedMemory() +
160 backtraces_.EstimateUsedMemory(); 160 backtraces_.EstimateUsedMemory();
161 overhead->Add("AllocationRegister", allocated, resident); 161 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerAllocationRegister,
162 allocated, resident);
162 } 163 }
163 164
164 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace( 165 AllocationRegister::BacktraceMap::KVIndex AllocationRegister::InsertBacktrace(
165 const Backtrace& backtrace) { 166 const Backtrace& backtrace) {
166 auto index = backtraces_.Insert(backtrace, 0).first; 167 auto index = backtraces_.Insert(backtrace, 0).first;
167 if (index == BacktraceMap::kInvalidKVIndex) 168 if (index == BacktraceMap::kInvalidKVIndex)
168 return kOutOfStorageBacktraceIndex; 169 return kOutOfStorageBacktraceIndex;
169 auto& backtrace_and_count = backtraces_.Get(index); 170 auto& backtrace_and_count = backtraces_.Get(index);
170 backtrace_and_count.second++; 171 backtrace_and_count.second++;
171 return index; 172 return index;
(...skipping 13 matching lines...) Expand all
185 const auto& address_and_info = allocations_.Get(index); 186 const auto& address_and_info = allocations_.Get(index);
186 const auto& backtrace_and_count = 187 const auto& backtrace_and_count =
187 backtraces_.Get(address_and_info.second.backtrace_index); 188 backtraces_.Get(address_and_info.second.backtrace_index);
188 return {address_and_info.first, address_and_info.second.size, 189 return {address_and_info.first, address_and_info.second.size,
189 AllocationContext(backtrace_and_count.first, 190 AllocationContext(backtrace_and_count.first,
190 address_and_info.second.type_name)}; 191 address_and_info.second.type_name)};
191 } 192 }
192 193
193 } // namespace trace_event 194 } // namespace trace_event
194 } // namespace base 195 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_stack_frame_deduplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698