| OLD | NEW |
| 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::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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 // Find ASYNC_BEGIN events that have a corresponding ASYNC_END event. | 346 // Find ASYNC_BEGIN events that have a corresponding ASYNC_END event. |
| 347 static Query MatchAsyncBeginWithNext() { | 347 static Query MatchAsyncBeginWithNext() { |
| 348 return (Query(EVENT_PHASE) == | 348 return (Query(EVENT_PHASE) == |
| 349 Query::Phase(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && | 349 Query::Phase(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && |
| 350 Query(EVENT_HAS_OTHER); | 350 Query(EVENT_HAS_OTHER); |
| 351 } | 351 } |
| 352 | 352 |
| 353 // Find BEGIN events of given |name| which also have associated END events. | 353 // Find BEGIN events of given |name| which also have associated END events. |
| 354 static Query MatchBeginName(const std::string& name) { | 354 static Query MatchBeginName(const std::string& name) { |
| 355 return (Query(EVENT_NAME) == name) && MatchBeginWithEnd(); | 355 return (Query(EVENT_NAME) == Query(name)) && MatchBeginWithEnd(); |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Match given Process ID and Thread ID. | 358 // Match given Process ID and Thread ID. |
| 359 static Query MatchThread(const TraceEvent::ProcessThreadID& thread) { | 359 static Query MatchThread(const TraceEvent::ProcessThreadID& thread) { |
| 360 return (Query(EVENT_PID) == Query::Int(thread.process_id)) && | 360 return (Query(EVENT_PID) == Query::Int(thread.process_id)) && |
| 361 (Query(EVENT_TID) == Query::Int(thread.thread_id)); | 361 (Query(EVENT_TID) == Query::Int(thread.thread_id)); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Match event pair that spans multiple threads. | 364 // Match event pair that spans multiple threads. |
| 365 static Query MatchCrossThread() { | 365 static Query MatchCrossThread() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 enum QueryType { | 446 enum QueryType { |
| 447 QUERY_BOOLEAN_OPERATOR, | 447 QUERY_BOOLEAN_OPERATOR, |
| 448 QUERY_ARITHMETIC_OPERATOR, | 448 QUERY_ARITHMETIC_OPERATOR, |
| 449 QUERY_EVENT_MEMBER, | 449 QUERY_EVENT_MEMBER, |
| 450 QUERY_NUMBER, | 450 QUERY_NUMBER, |
| 451 QUERY_STRING | 451 QUERY_STRING |
| 452 }; | 452 }; |
| 453 | 453 |
| 454 // Compare with the given member. | 454 // Compare with the given member. |
| 455 Query(TraceEventMember member); | 455 explicit Query(TraceEventMember member); |
| 456 | 456 |
| 457 // Compare with the given member argument value. | 457 // Compare with the given member argument value. |
| 458 Query(TraceEventMember member, const std::string& arg_name); | 458 Query(TraceEventMember member, const std::string& arg_name); |
| 459 | 459 |
| 460 // Compare with the given string. | 460 // Compare with the given string. |
| 461 Query(const std::string& str); | 461 explicit Query(const std::string& str); |
| 462 | 462 |
| 463 // Compare with the given number. | 463 // Compare with the given number. |
| 464 Query(double num); | 464 explicit Query(double num); |
| 465 | 465 |
| 466 // Construct a boolean Query that returns (left <binary_op> right). | 466 // Construct a boolean Query that returns (left <binary_op> right). |
| 467 Query(const Query& left, const Query& right, Operator binary_op); | 467 Query(const Query& left, const Query& right, Operator binary_op); |
| 468 | 468 |
| 469 // Construct a boolean Query that returns (<binary_op> left). | 469 // Construct a boolean Query that returns (<binary_op> left). |
| 470 Query(const Query& left, Operator unary_op); | 470 Query(const Query& left, Operator unary_op); |
| 471 | 471 |
| 472 // Try to compare left_ against right_ based on operator_. | 472 // Try to compare left_ against right_ based on operator_. |
| 473 // If either left or right does not convert to double, false is returned. | 473 // If either left or right does not convert to double, false is returned. |
| 474 // Otherwise, true is returned and |result| is set to the comparison result. | 474 // Otherwise, true is returned and |result| is set to the comparison result. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 675 |
| 676 // Count all matches. | 676 // Count all matches. |
| 677 static inline size_t CountMatches(const TraceEventVector& events, | 677 static inline size_t CountMatches(const TraceEventVector& events, |
| 678 const Query& query) { | 678 const Query& query) { |
| 679 return CountMatches(events, query, 0u, events.size()); | 679 return CountMatches(events, query, 0u, events.size()); |
| 680 } | 680 } |
| 681 | 681 |
| 682 } // namespace trace_analyzer | 682 } // namespace trace_analyzer |
| 683 | 683 |
| 684 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ | 684 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ |
| OLD | NEW |