OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_TIMELINE_H_ | 5 #ifndef VM_TIMELINE_H_ |
6 #define VM_TIMELINE_H_ | 6 #define VM_TIMELINE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/bitfield.h" | 9 #include "vm/bitfield.h" |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 friend class ReclaimBlocksIsolateVisitor; | 80 friend class ReclaimBlocksIsolateVisitor; |
81 }; | 81 }; |
82 | 82 |
83 | 83 |
84 // You should get a |TimelineEvent| from a |TimelineStream|. | 84 // You should get a |TimelineEvent| from a |TimelineStream|. |
85 class TimelineEvent { | 85 class TimelineEvent { |
86 public: | 86 public: |
87 // Keep in sync with StateBits below. | 87 // Keep in sync with StateBits below. |
88 enum EventType { | 88 enum EventType { |
89 kNone, | 89 kNone, |
| 90 kBegin, |
| 91 kEnd, |
90 kDuration, | 92 kDuration, |
91 kInstant, | 93 kInstant, |
92 kAsyncBegin, | 94 kAsyncBegin, |
93 kAsyncInstant, | 95 kAsyncInstant, |
94 kAsyncEnd, | 96 kAsyncEnd, |
95 kNumEventTypes, | 97 kNumEventTypes, |
96 }; | 98 }; |
97 | 99 |
98 TimelineEvent(); | 100 TimelineEvent(); |
99 ~TimelineEvent(); | 101 ~TimelineEvent(); |
(...skipping 14 matching lines...) Expand all Loading... |
114 int64_t async_id); | 116 int64_t async_id); |
115 | 117 |
116 void DurationBegin(const char* label); | 118 void DurationBegin(const char* label); |
117 void DurationEnd(); | 119 void DurationEnd(); |
118 void Instant(const char* label); | 120 void Instant(const char* label); |
119 | 121 |
120 void Duration(const char* label, | 122 void Duration(const char* label, |
121 int64_t start_micros, | 123 int64_t start_micros, |
122 int64_t end_micros); | 124 int64_t end_micros); |
123 | 125 |
| 126 void Begin(const char* label, |
| 127 int64_t micros); |
| 128 |
| 129 void End(const char* label, |
| 130 int64_t micros); |
| 131 |
124 // Set the number of arguments in the event. | 132 // Set the number of arguments in the event. |
125 void SetNumArguments(intptr_t length); | 133 void SetNumArguments(intptr_t length); |
126 // |name| must be a compile time constant. Takes ownership of |argumentp|. | 134 // |name| must be a compile time constant. Takes ownership of |argumentp|. |
127 void SetArgument(intptr_t i, const char* name, char* argument); | 135 void SetArgument(intptr_t i, const char* name, char* argument); |
128 // |name| must be a compile time constant. Copies |argument|. | 136 // |name| must be a compile time constant. Copies |argument|. |
129 void CopyArgument(intptr_t i, const char* name, const char* argument); | 137 void CopyArgument(intptr_t i, const char* name, const char* argument); |
130 // |name| must be a compile time constant. | 138 // |name| must be a compile time constant. |
131 void FormatArgument(intptr_t i, | 139 void FormatArgument(intptr_t i, |
132 const char* name, | 140 const char* name, |
133 const char* fmt, ...) PRINTF_ATTRIBUTE(4, 5); | 141 const char* fmt, ...) PRINTF_ATTRIBUTE(4, 5); |
(...skipping 25 matching lines...) Expand all Loading... |
159 | 167 |
160 const char* label() const { | 168 const char* label() const { |
161 return label_; | 169 return label_; |
162 } | 170 } |
163 | 171 |
164 // Does this duration end before |micros| ? | 172 // Does this duration end before |micros| ? |
165 bool DurationFinishedBefore(int64_t micros) const { | 173 bool DurationFinishedBefore(int64_t micros) const { |
166 return TimeEnd() <= micros; | 174 return TimeEnd() <= micros; |
167 } | 175 } |
168 | 176 |
| 177 bool IsDuration() const { |
| 178 return (event_type() == kDuration); |
| 179 } |
| 180 |
| 181 bool IsBegin() const { |
| 182 return (event_type() == kBegin); |
| 183 } |
| 184 |
| 185 bool IsEnd() const { |
| 186 return (event_type() == kEnd); |
| 187 } |
| 188 |
| 189 // Is this event a synchronous begin or end event? |
| 190 bool IsBeginOrEnd() const { |
| 191 return IsBegin() || IsEnd(); |
| 192 } |
| 193 |
169 // Does this duration fully contain |other| ? | 194 // Does this duration fully contain |other| ? |
170 bool DurationContains(TimelineEvent* other) const { | 195 bool DurationContains(TimelineEvent* other) const { |
171 ASSERT(IsFinishedDuration()); | 196 ASSERT(IsFinishedDuration()); |
172 ASSERT(other->IsFinishedDuration()); | 197 if (other->IsBegin()) { |
173 if (other->TimeOrigin() < TimeOrigin()) { | 198 if (other->TimeOrigin() < TimeOrigin()) { |
174 return false; | 199 return false; |
| 200 } |
| 201 if (other->TimeOrigin() > TimeEnd()) { |
| 202 return false; |
| 203 } |
| 204 return true; |
| 205 } else { |
| 206 ASSERT(other->IsFinishedDuration()); |
| 207 if (other->TimeOrigin() < TimeOrigin()) { |
| 208 return false; |
| 209 } |
| 210 if (other->TimeEnd() < TimeOrigin()) { |
| 211 return false; |
| 212 } |
| 213 if (other->TimeOrigin() > TimeEnd()) { |
| 214 return false; |
| 215 } |
| 216 if (other->TimeEnd() > TimeEnd()) { |
| 217 return false; |
| 218 } |
| 219 return true; |
175 } | 220 } |
176 if (other->TimeEnd() < TimeOrigin()) { | |
177 return false; | |
178 } | |
179 if (other->TimeOrigin() > TimeEnd()) { | |
180 return false; | |
181 } | |
182 if (other->TimeEnd() > TimeEnd()) { | |
183 return false; | |
184 } | |
185 return true; | |
186 } | 221 } |
187 | 222 |
188 private: | 223 private: |
189 struct TimelineEventArgument { | 224 struct TimelineEventArgument { |
190 const char* name; | 225 const char* name; |
191 char* value; | 226 char* value; |
192 }; | 227 }; |
193 | 228 |
194 int64_t timestamp0_; | 229 int64_t timestamp0_; |
195 int64_t timestamp1_; | 230 int64_t timestamp1_; |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 750 |
716 private: | 751 private: |
717 intptr_t cursor_; | 752 intptr_t cursor_; |
718 intptr_t num_events_; | 753 intptr_t num_events_; |
719 TimelineEventRecorder* recorder_; | 754 TimelineEventRecorder* recorder_; |
720 }; | 755 }; |
721 | 756 |
722 } // namespace dart | 757 } // namespace dart |
723 | 758 |
724 #endif // VM_TIMELINE_H_ | 759 #endif // VM_TIMELINE_H_ |
OLD | NEW |