OLD | NEW |
---|---|
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 | 246 |
247 // Compare with the given string pattern. Only works with == and != operators. | 247 // Compare with the given string pattern. Only works with == and != operators. |
248 // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*") | 248 // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*") |
249 static Query Pattern(const std::string& pattern); | 249 static Query Pattern(const std::string& pattern); |
250 | 250 |
251 // Common queries: | 251 // Common queries: |
252 | 252 |
253 // Find BEGIN events that have a corresponding END event. | 253 // Find BEGIN events that have a corresponding END event. |
254 static Query MatchBeginWithEnd() { | 254 static Query MatchBeginWithEnd() { |
255 return (Query(EVENT_PHASE) == | 255 return (Query(EVENT_PHASE) == |
256 Query::Phase(base::debug::TRACE_EVENT_PHASE_BEGIN)) && | 256 Query::Phase(TRACE_EVENT_PHASE_BEGIN)) && |
257 Query(EVENT_HAS_OTHER); | 257 Query(EVENT_HAS_OTHER); |
258 } | 258 } |
259 | 259 |
260 // Find BEGIN events of given |name| which also have associated END events. | 260 // Find BEGIN events of given |name| which also have associated END events. |
261 static Query MatchBeginName(const std::string& name) { | 261 static Query MatchBeginName(const std::string& name) { |
262 return (Query(EVENT_NAME) == name) && MatchBeginWithEnd(); | 262 return (Query(EVENT_NAME) == name) && MatchBeginWithEnd(); |
263 } | 263 } |
264 | 264 |
265 // Match given Process ID and Thread ID. | 265 // Match given Process ID and Thread ID. |
266 static Query MatchThread(const TraceEvent::ProcessThreadID& thread) { | 266 static Query MatchThread(const TraceEvent::ProcessThreadID& thread) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 | 405 |
406 Query query_; | 406 Query query_; |
407 }; | 407 }; |
408 | 408 |
409 // TraceAnalyzer helps tests search for trace events. | 409 // TraceAnalyzer helps tests search for trace events. |
410 class TraceAnalyzer { | 410 class TraceAnalyzer { |
411 public: | 411 public: |
412 typedef std::vector<const TraceEvent*> TraceEventVector; | 412 typedef std::vector<const TraceEvent*> TraceEventVector; |
413 | 413 |
414 struct Stats { | 414 struct Stats { |
415 double min_us; | 415 double min_us; |
jar (doing other things)
2011/12/02 00:09:32
nit: Abbreviations are frowned on... IMO, *_micros
| |
416 double max_us; | 416 double max_us; |
417 double mean_us; | 417 double mean_us; |
418 double standard_deviation_us; | 418 double standard_deviation_us; |
419 }; | 419 }; |
420 | 420 |
421 ~TraceAnalyzer(); | 421 ~TraceAnalyzer(); |
422 | 422 |
423 // Use trace events from JSON string generated by tracing API. | 423 // Use trace events from JSON string generated by tracing API. |
424 // Returns non-NULL if the JSON is successfully parsed. | 424 // Returns non-NULL if the JSON is successfully parsed. |
425 static TraceAnalyzer* Create(const std::string& json_events) | 425 static TraceAnalyzer* Create(const std::string& json_events) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 std::map<TraceEvent::ProcessThreadID, std::string> thread_names_; | 483 std::map<TraceEvent::ProcessThreadID, std::string> thread_names_; |
484 std::vector<TraceEvent> raw_events_; | 484 std::vector<TraceEvent> raw_events_; |
485 bool allow_assocation_changes_; | 485 bool allow_assocation_changes_; |
486 | 486 |
487 DISALLOW_COPY_AND_ASSIGN(TraceAnalyzer); | 487 DISALLOW_COPY_AND_ASSIGN(TraceAnalyzer); |
488 }; | 488 }; |
489 | 489 |
490 } // namespace trace_analyzer | 490 } // namespace trace_analyzer |
491 | 491 |
492 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ | 492 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ |
OLD | NEW |