Chromium Code Reviews| Index: runtime/vm/timeline.h |
| diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h |
| index 3cda6c92337ec8ffb7081a83bc74852a510ae0f1..01dfe7a99f6054a8ed7649de69b90328a96412b6 100644 |
| --- a/runtime/vm/timeline.h |
| +++ b/runtime/vm/timeline.h |
| @@ -81,9 +81,17 @@ class TimelineEvent { |
| return EventTypeField::decode(state_); |
| } |
| + bool IsFinishedDuration() const { |
| + return (event_type() == kDuration) && (timestamp1_ > timestamp0_); |
| + } |
| + |
| int64_t TimeOrigin() const; |
| int64_t AsyncId() const; |
| int64_t TimeDuration() const; |
| + int64_t TimeEnd() const { |
| + ASSERT(IsFinishedDuration()); |
| + return timestamp1_; |
| + } |
| void PrintJSON(JSONStream* stream) const; |
| @@ -95,6 +103,30 @@ class TimelineEvent { |
| return label_; |
| } |
| + // Does this duration end before |micros| ? |
| + bool DurationFinishedBefore(int64_t micros) const { |
| + return TimeEnd() <= micros; |
| + } |
| + |
| + // Does this duration contain |other| ? |
|
rmacnak
2015/08/14 18:09:34
^fully contain
Cutch
2015/08/14 18:11:55
Done.
|
| + bool DurationContains(TimelineEvent* other) const { |
| + ASSERT(IsFinishedDuration()); |
| + ASSERT(other->IsFinishedDuration()); |
| + if (other->TimeOrigin() < TimeOrigin()) { |
| + return false; |
| + } |
| + if (other->TimeEnd() < TimeOrigin()) { |
| + return false; |
| + } |
| + if (other->TimeOrigin() > TimeEnd()) { |
| + return false; |
| + } |
| + if (other->TimeEnd() > TimeEnd()) { |
| + return false; |
| + } |
| + return true; |
| + } |
| + |
| private: |
| struct TimelineEventArgument { |
| const char* name; |
| @@ -371,6 +403,7 @@ class TimelineEventRecorder { |
| friend class TimelineEventBlockIterator; |
| friend class TimelineStream; |
| + friend class TimelineTestHelper; |
| friend class Isolate; |
| private: |
| @@ -468,8 +501,13 @@ class TimelineEventEndlessRecorder : public TimelineEventRecorder { |
| TimelineEventBlock* GetNewBlockLocked(); |
| void PrintJSONEvents(JSONArray* array) const; |
| + // Useful only for testing. Only works for one thread. |
| + void Clear(); |
| + |
| TimelineEventBlock* head_; |
| intptr_t block_index_; |
| + |
| + friend class TimelineTestHelper; |
| }; |