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

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

Issue 2980083002: [tracing] Add trace events to key heap profiler functions. (Closed)
Patch Set: Don't trace in TraceLog Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_string_deduplicator.h" 5 #include "base/trace_event/heap_profiler_string_deduplicator.h"
6 6
7 #include "base/trace_event/memory_usage_estimator.h" 7 #include "base/trace_event/memory_usage_estimator.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "base/trace_event/trace_event_argument.h" 9 #include "base/trace_event/trace_event_argument.h"
10 #include "base/trace_event/trace_event_memory_overhead.h" 10 #include "base/trace_event/trace_event_memory_overhead.h"
(...skipping 20 matching lines...) Expand all
31 // Insert new mapping. Note that |string_ids_| keys reference values 31 // Insert new mapping. Note that |string_ids_| keys reference values
32 // from |strings_|. 32 // from |strings_|.
33 int string_id = static_cast<int>(strings_.size()); 33 int string_id = static_cast<int>(strings_.size());
34 strings_.push_back(string.as_string()); 34 strings_.push_back(string.as_string());
35 auto iter_and_flag = string_ids_.insert({strings_.back(), string_id}); 35 auto iter_and_flag = string_ids_.insert({strings_.back(), string_id});
36 DCHECK(iter_and_flag.second); // insert() must succeed 36 DCHECK(iter_and_flag.second); // insert() must succeed
37 return string_id; 37 return string_id;
38 } 38 }
39 39
40 void StringDeduplicator::SerializeIncrementally(TracedValue* traced_value) { 40 void StringDeduplicator::SerializeIncrementally(TracedValue* traced_value) {
41 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("memory-infra"),
42 "StringDeduplicator::SerializeIncrementally");
41 for (; last_serialized_index_ != strings_.size(); ++last_serialized_index_) { 43 for (; last_serialized_index_ != strings_.size(); ++last_serialized_index_) {
42 traced_value->BeginDictionary(); 44 traced_value->BeginDictionary();
43 traced_value->SetInteger("id", last_serialized_index_); 45 traced_value->SetInteger("id", last_serialized_index_);
44 traced_value->SetString("string", strings_[last_serialized_index_]); 46 traced_value->SetString("string", strings_[last_serialized_index_]);
45 traced_value->EndDictionary(); 47 traced_value->EndDictionary();
46 } 48 }
47 } 49 }
48 50
49 void StringDeduplicator::EstimateTraceMemoryOverhead( 51 void StringDeduplicator::EstimateTraceMemoryOverhead(
50 TraceEventMemoryOverhead* overhead) { 52 TraceEventMemoryOverhead* overhead) {
51 size_t memory_usage = 53 size_t memory_usage =
52 EstimateMemoryUsage(string_ids_) + EstimateMemoryUsage(strings_); 54 EstimateMemoryUsage(string_ids_) + EstimateMemoryUsage(strings_);
53 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerStringDeduplicator, 55 overhead->Add(TraceEventMemoryOverhead::kHeapProfilerStringDeduplicator,
54 sizeof(StringDeduplicator) + memory_usage); 56 sizeof(StringDeduplicator) + memory_usage);
55 } 57 }
56 58
57 } // namespace trace_event 59 } // namespace trace_event
58 } // namespace base 60 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_stack_frame_deduplicator.cc ('k') | base/trace_event/heap_profiler_type_name_deduplicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698