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

Unified Diff: base/test/trace_event_analyzer.h

Issue 8900001: Add searching features to new TraceEventVector class for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const ref params Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/trace_event_analyzer.h
diff --git a/base/test/trace_event_analyzer.h b/base/test/trace_event_analyzer.h
index 5e40a062727e9b74755b299d9f4f591973c5e281..8f25cd8f2483b863e43ed2958d2f255f8ded9cf3 100644
--- a/base/test/trace_event_analyzer.h
+++ b/base/test/trace_event_analyzer.h
@@ -170,6 +170,8 @@ struct TraceEvent {
const TraceEvent* other_event;
};
+typedef std::vector<const TraceEvent*> TraceEventVector;
+
// Pass these values to Query to compare with the corresponding member of a
// TraceEvent. Unless otherwise specfied, the usage is Query(ENUM_MEMBER).
enum TraceEventMember {
@@ -418,15 +420,6 @@ class QueryNode : public base::RefCounted<QueryNode> {
// TraceAnalyzer helps tests search for trace events.
class TraceAnalyzer {
public:
- typedef std::vector<const TraceEvent*> TraceEventVector;
-
- struct Stats {
- double min_us;
- double max_us;
- double mean_us;
- double standard_deviation_us;
- };
-
~TraceAnalyzer();
// Use trace events from JSON string generated by tracing API.
@@ -474,6 +467,10 @@ class TraceAnalyzer {
const Query& second,
const Query& match);
+ // For each event, copy its arguments to the other_event argument map. If
+ // argument name already exists, it will not be overwritten.
+ void MergeAssociatedEventArgs();
+
// Find all events that match query and replace output vector.
size_t FindEvents(const Query& query, TraceEventVector* output);
@@ -482,10 +479,6 @@ class TraceAnalyzer {
const std::string& GetThreadName(const TraceEvent::ProcessThreadID& thread);
- // Calculate min/max/mean and standard deviation from the times between
- // adjacent events.
- static bool GetRateStats(const TraceEventVector& events, Stats* stats);
-
private:
TraceAnalyzer();
@@ -501,6 +494,56 @@ class TraceAnalyzer {
DISALLOW_COPY_AND_ASSIGN(TraceAnalyzer);
};
+// Utility functions for TraceEventVector.
+
+struct RateStats {
+ double min_us;
+ double max_us;
+ double mean_us;
+ double standard_deviation_us;
+};
+
+// Calculate min/max/mean and standard deviation from the times between
+// adjacent events.
+bool GetRateStats(const TraceEventVector& events, RateStats* stats);
+
+// Starting from |position|, find the first event that matches |query|.
+// Returns true if found, false otherwise.
+bool FindFirstOf(const TraceEventVector& events,
+ const Query& query,
+ size_t position,
+ size_t* return_index);
+
+// Starting from |position|, find the last event that matches |query|.
+// Returns true if found, false otherwise.
+bool FindLastOf(const TraceEventVector& events,
+ const Query& query,
+ size_t position,
+ size_t* return_index);
+
+// Find the closest events to |position| in time that match |query|.
+// return_second_closest may be NULL. Closeness is determined by comparing
+// with the event timestamp.
+// Returns true if found, false otherwise. If both return parameters are
+// requested, both must be found for a successful result.
+bool FindClosest(const TraceEventVector& events,
+ const Query& query,
+ size_t position,
+ size_t* return_closest,
+ size_t* return_second_closest);
+
+// Count matches, inclusive of |begin_position|, exclusive of |end_position|.
+size_t CountMatches(const TraceEventVector& events,
+ const Query& query,
+ size_t begin_position,
+ size_t end_position);
+
+// Count all matches.
+static inline size_t CountMatches(const TraceEventVector& events,
+ const Query& query) {
+ return CountMatches(events, query, 0u, events.size());
+}
+
} // namespace trace_analyzer
#endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_
« no previous file with comments | « no previous file | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698