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

Side by Side Diff: base/test/trace_event_analyzer.h

Issue 1776673002: base: Add blame context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows build fix. Created 4 years, 9 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 | « base/BUILD.gn ('k') | base/test/trace_event_analyzer.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Use trace_analyzer::Query and trace_analyzer::TraceAnalyzer to search for 5 // Use trace_analyzer::Query and trace_analyzer::TraceAnalyzer to search for
6 // specific trace events that were generated by the trace_event.h API. 6 // specific trace events that were generated by the trace_event.h API.
7 // 7 //
8 // Basic procedure: 8 // Basic procedure:
9 // - Get trace events JSON string from base::trace_event::TraceLog. 9 // - Get trace events JSON string from base::trace_event::TraceLog.
10 // - Create TraceAnalyzer with JSON string. 10 // - Create TraceAnalyzer with JSON string.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool operator< (const ProcessThreadID& rhs) const { 104 bool operator< (const ProcessThreadID& rhs) const {
105 if (process_id != rhs.process_id) 105 if (process_id != rhs.process_id)
106 return process_id < rhs.process_id; 106 return process_id < rhs.process_id;
107 return thread_id < rhs.thread_id; 107 return thread_id < rhs.thread_id;
108 } 108 }
109 int process_id; 109 int process_id;
110 int thread_id; 110 int thread_id;
111 }; 111 };
112 112
113 TraceEvent(); 113 TraceEvent();
114 TraceEvent(const TraceEvent& other); 114 TraceEvent(TraceEvent&& other);
115 ~TraceEvent(); 115 ~TraceEvent();
116 116
117 bool SetFromJSON(const base::Value* event_value) WARN_UNUSED_RESULT; 117 bool SetFromJSON(const base::Value* event_value) WARN_UNUSED_RESULT;
118 118
119 bool operator< (const TraceEvent& rhs) const { 119 bool operator< (const TraceEvent& rhs) const {
120 return timestamp < rhs.timestamp; 120 return timestamp < rhs.timestamp;
121 } 121 }
122 122
123 TraceEvent& operator=(TraceEvent&& rhs);
124
123 bool has_other_event() const { return other_event; } 125 bool has_other_event() const { return other_event; }
124 126
125 // Returns absolute duration in microseconds between this event and other 127 // Returns absolute duration in microseconds between this event and other
126 // event. Must have already verified that other_event exists by 128 // event. Must have already verified that other_event exists by
127 // Query(EVENT_HAS_OTHER) or by calling has_other_event(). 129 // Query(EVENT_HAS_OTHER) or by calling has_other_event().
128 double GetAbsTimeToOtherEvent() const; 130 double GetAbsTimeToOtherEvent() const;
129 131
130 // Return the argument value if it exists and it is a string. 132 // Return the argument value if it exists and it is a string.
131 bool GetArgAsString(const std::string& name, std::string* arg) const; 133 bool GetArgAsString(const std::string& name, std::string* arg) const;
132 // Return the argument value if it exists and it is a number. 134 // Return the argument value if it exists and it is a number.
133 bool GetArgAsNumber(const std::string& name, double* arg) const; 135 bool GetArgAsNumber(const std::string& name, double* arg) const;
136 // Return the argument value if it exists.
137 bool GetArgAsValue(const std::string& name,
138 scoped_ptr<base::Value>* arg) const;
134 139
135 // Check if argument exists and is string. 140 // Check if argument exists and is string.
136 bool HasStringArg(const std::string& name) const; 141 bool HasStringArg(const std::string& name) const;
137 // Check if argument exists and is number (double, int or bool). 142 // Check if argument exists and is number (double, int or bool).
138 bool HasNumberArg(const std::string& name) const; 143 bool HasNumberArg(const std::string& name) const;
144 // Check if argument exists.
145 bool HasArg(const std::string& name) const;
139 146
140 // Get known existing arguments as specific types. 147 // Get known existing arguments as specific types.
141 // Useful when you have already queried the argument with 148 // Useful when you have already queried the argument with
142 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG). 149 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG).
143 std::string GetKnownArgAsString(const std::string& name) const; 150 std::string GetKnownArgAsString(const std::string& name) const;
144 double GetKnownArgAsDouble(const std::string& name) const; 151 double GetKnownArgAsDouble(const std::string& name) const;
145 int GetKnownArgAsInt(const std::string& name) const; 152 int GetKnownArgAsInt(const std::string& name) const;
146 bool GetKnownArgAsBool(const std::string& name) const; 153 bool GetKnownArgAsBool(const std::string& name) const;
154 scoped_ptr<base::Value> GetKnownArgAsValue(const std::string& name) const;
147 155
148 // Process ID and Thread ID. 156 // Process ID and Thread ID.
149 ProcessThreadID thread; 157 ProcessThreadID thread;
150 158
151 // Time since epoch in microseconds. 159 // Time since epoch in microseconds.
152 // Stored as double to match its JSON representation. 160 // Stored as double to match its JSON representation.
153 double timestamp; 161 double timestamp;
154
155 double duration; 162 double duration;
156
157 char phase; 163 char phase;
158
159 std::string category; 164 std::string category;
160
161 std::string name; 165 std::string name;
162
163 std::string id; 166 std::string id;
164 167
165 // All numbers and bool values from TraceEvent args are cast to double. 168 // All numbers and bool values from TraceEvent args are cast to double.
166 // bool becomes 1.0 (true) or 0.0 (false). 169 // bool becomes 1.0 (true) or 0.0 (false).
167 std::map<std::string, double> arg_numbers; 170 std::map<std::string, double> arg_numbers;
168
169 std::map<std::string, std::string> arg_strings; 171 std::map<std::string, std::string> arg_strings;
172 std::map<std::string, scoped_ptr<base::Value>> arg_values;
170 173
171 // The other event associated with this event (or NULL). 174 // The other event associated with this event (or NULL).
172 const TraceEvent* other_event; 175 const TraceEvent* other_event;
173 }; 176 };
174 177
175 typedef std::vector<const TraceEvent*> TraceEventVector; 178 typedef std::vector<const TraceEvent*> TraceEventVector;
176 179
177 class Query { 180 class Query {
178 public: 181 public:
179 Query(const Query& query); 182 Query(const Query& query);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 705
703 // Count all matches. 706 // Count all matches.
704 static inline size_t CountMatches(const TraceEventVector& events, 707 static inline size_t CountMatches(const TraceEventVector& events,
705 const Query& query) { 708 const Query& query) {
706 return CountMatches(events, query, 0u, events.size()); 709 return CountMatches(events, query, 0u, events.size());
707 } 710 }
708 711
709 } // namespace trace_analyzer 712 } // namespace trace_analyzer
710 713
711 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ 714 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698