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

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

Issue 9155024: Allow tracing in third_party libraries (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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::debug::TraceLog. 9 // - Get trace events JSON string from base::debug::TraceLog.
10 // - Create TraceAnalyzer with JSON string. 10 // - Create TraceAnalyzer with JSON string.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 int GetKnownArgAsInt(const std::string& name) const; 145 int GetKnownArgAsInt(const std::string& name) const;
146 bool GetKnownArgAsBool(const std::string& name) const; 146 bool GetKnownArgAsBool(const std::string& name) const;
147 147
148 // Process ID and Thread ID. 148 // Process ID and Thread ID.
149 ProcessThreadID thread; 149 ProcessThreadID thread;
150 150
151 // Time since epoch in microseconds. 151 // Time since epoch in microseconds.
152 // Stored as double to match its JSON representation. 152 // Stored as double to match its JSON representation.
153 double timestamp; 153 double timestamp;
154 154
155 base::debug::TraceEventPhase phase; 155 char phase;
156 156
157 std::string category; 157 std::string category;
158 158
159 std::string name; 159 std::string name;
160 160
161 std::string id; 161 std::string id;
162 162
163 // All numbers and bool values from TraceEvent args are cast to double. 163 // All numbers and bool values from TraceEvent args are cast to double.
164 // bool becomes 1.0 (true) or 0.0 (false). 164 // bool becomes 1.0 (true) or 0.0 (false).
165 std::map<std::string, double> arg_numbers; 165 std::map<std::string, double> arg_numbers;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 // Compare with the given number. 242 // Compare with the given number.
243 static Query Double(double num); 243 static Query Double(double num);
244 static Query Int(int32 num); 244 static Query Int(int32 num);
245 static Query Uint(uint32 num); 245 static Query Uint(uint32 num);
246 246
247 // Compare with the given bool. 247 // Compare with the given bool.
248 static Query Bool(bool boolean); 248 static Query Bool(bool boolean);
249 249
250 // Compare with the given phase. 250 // Compare with the given phase.
251 static Query Phase(base::debug::TraceEventPhase phase); 251 static Query Phase(char phase);
252 252
253 // Compare with the given string pattern. Only works with == and != operators. 253 // Compare with the given string pattern. Only works with == and != operators.
254 // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*") 254 // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*")
255 static Query Pattern(const std::string& pattern); 255 static Query Pattern(const std::string& pattern);
256 256
257 // Common queries: 257 // Common queries:
258 258
259 // Find BEGIN events that have a corresponding END event. 259 // Find BEGIN events that have a corresponding END event.
260 static Query MatchBeginWithEnd() { 260 static Query MatchBeginWithEnd() {
261 return (Query(EVENT_PHASE) == Query::Phase(TRACE_EVENT_PHASE_BEGIN)) && 261 return (Query(EVENT_PHASE) == Query::Phase(TRACE_EVENT_PHASE_BEGIN)) &&
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 bool GetAsDouble(const TraceEvent& event, double* num) const; 367 bool GetAsDouble(const TraceEvent& event, double* num) const;
368 368
369 // Attempt to convert this Query to a string. On success, true is returned 369 // Attempt to convert this Query to a string. On success, true is returned
370 // and the string value is stored in |str|. 370 // and the string value is stored in |str|.
371 bool GetAsString(const TraceEvent& event, std::string* str) const; 371 bool GetAsString(const TraceEvent& event, std::string* str) const;
372 372
373 // Evaluate this Query as an arithmetic operator on left_ and right_. 373 // Evaluate this Query as an arithmetic operator on left_ and right_.
374 bool EvaluateArithmeticOperator(const TraceEvent& event, 374 bool EvaluateArithmeticOperator(const TraceEvent& event,
375 double* num) const; 375 double* num) const;
376 376
377 // For QUERY_EVENT_MEMBER Query: attempt to get the value of the Query. 377 // For QUERY_EVENT_MEMBER Query: attempt to get the double value of the Query.
378 // The TraceValue will either be TRACE_TYPE_DOUBLE, TRACE_TYPE_STRING, 378 bool GetMemberValueAsDouble(const TraceEvent& event, double* num) const;
379 // or if requested member does not exist, it will be TRACE_TYPE_UNDEFINED. 379
380 base::debug::TraceValue GetMemberValue(const TraceEvent& event) const; 380 // For QUERY_EVENT_MEMBER Query: attempt to get the string value of the Query.
381 bool GetMemberValueAsString(const TraceEvent& event, std::string* num) const;
381 382
382 // Does this Query represent a value? 383 // Does this Query represent a value?
383 bool is_value() const { return type_ != QUERY_BOOLEAN_OPERATOR; } 384 bool is_value() const { return type_ != QUERY_BOOLEAN_OPERATOR; }
384 385
385 bool is_unary_operator() const { 386 bool is_unary_operator() const {
386 return operator_ == OP_NOT || operator_ == OP_NEGATE; 387 return operator_ == OP_NOT || operator_ == OP_NEGATE;
387 } 388 }
388 389
389 bool is_comparison_operator() const { 390 bool is_comparison_operator() const {
390 return operator_ != OP_INVALID && operator_ < OP_AND; 391 return operator_ != OP_INVALID && operator_ < OP_AND;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 541
541 // Count all matches. 542 // Count all matches.
542 static inline size_t CountMatches(const TraceEventVector& events, 543 static inline size_t CountMatches(const TraceEventVector& events,
543 const Query& query) { 544 const Query& query) {
544 return CountMatches(events, query, 0u, events.size()); 545 return CountMatches(events, query, 0u, events.size());
545 } 546 }
546 547
547 } // namespace trace_analyzer 548 } // namespace trace_analyzer
548 549
549 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ 550 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698