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 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" | 5 #include "base/trace_event/heap_profiler_stack_frame_deduplicator.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/trace_event/heap_profiler_string_deduplicator.h" | 14 #include "base/trace_event/heap_profiler_string_deduplicator.h" |
15 #include "base/trace_event/memory_usage_estimator.h" | 15 #include "base/trace_event/memory_usage_estimator.h" |
| 16 #include "base/trace_event/trace_event.h" |
16 #include "base/trace_event/trace_event_argument.h" | 17 #include "base/trace_event/trace_event_argument.h" |
17 #include "base/trace_event/trace_event_memory_overhead.h" | 18 #include "base/trace_event/trace_event_memory_overhead.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 namespace trace_event { | 21 namespace trace_event { |
21 | 22 |
22 StackFrameDeduplicator::FrameNode::FrameNode(StackFrame frame, | 23 StackFrameDeduplicator::FrameNode::FrameNode(StackFrame frame, |
23 int parent_frame_index) | 24 int parent_frame_index) |
24 : frame(frame), parent_frame_index(parent_frame_index) {} | 25 : frame(frame), parent_frame_index(parent_frame_index) {} |
25 StackFrameDeduplicator::FrameNode::FrameNode(const FrameNode& other) = default; | 26 StackFrameDeduplicator::FrameNode::FrameNode(const FrameNode& other) = default; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 frame_index = node->second; | 74 frame_index = node->second; |
74 } | 75 } |
75 | 76 |
76 nodes = &frames_[frame_index].children; | 77 nodes = &frames_[frame_index].children; |
77 } | 78 } |
78 | 79 |
79 return frame_index; | 80 return frame_index; |
80 } | 81 } |
81 | 82 |
82 void StackFrameDeduplicator::SerializeIncrementally(TracedValue* traced_value) { | 83 void StackFrameDeduplicator::SerializeIncrementally(TracedValue* traced_value) { |
| 84 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("memory-infra"), |
| 85 "StackFrameDeduplicator::SerializeIncrementally"); |
83 std::string stringify_buffer; | 86 std::string stringify_buffer; |
84 | 87 |
85 for (; last_exported_index_ < frames_.size(); ++last_exported_index_) { | 88 for (; last_exported_index_ < frames_.size(); ++last_exported_index_) { |
86 const auto& frame_node = frames_[last_exported_index_]; | 89 const auto& frame_node = frames_[last_exported_index_]; |
87 traced_value->BeginDictionary(); | 90 traced_value->BeginDictionary(); |
88 | 91 |
89 traced_value->SetInteger("id", last_exported_index_); | 92 traced_value->SetInteger("id", last_exported_index_); |
90 | 93 |
91 int name_string_id = 0; | 94 int name_string_id = 0; |
92 const StackFrame& frame = frame_node.frame; | 95 const StackFrame& frame = frame_node.frame; |
(...skipping 28 matching lines...) Expand all Loading... |
121 void StackFrameDeduplicator::EstimateTraceMemoryOverhead( | 124 void StackFrameDeduplicator::EstimateTraceMemoryOverhead( |
122 TraceEventMemoryOverhead* overhead) { | 125 TraceEventMemoryOverhead* overhead) { |
123 size_t memory_usage = | 126 size_t memory_usage = |
124 EstimateMemoryUsage(frames_) + EstimateMemoryUsage(roots_); | 127 EstimateMemoryUsage(frames_) + EstimateMemoryUsage(roots_); |
125 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerStackFrameDeduplicator, | 128 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerStackFrameDeduplicator, |
126 sizeof(StackFrameDeduplicator) + memory_usage); | 129 sizeof(StackFrameDeduplicator) + memory_usage); |
127 } | 130 } |
128 | 131 |
129 } // namespace trace_event | 132 } // namespace trace_event |
130 } // namespace base | 133 } // namespace base |
OLD | NEW |