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

Side by Side Diff: runtime/vm/timeline.h

Issue 1960483002: Include thread CPU time in Timeline (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months 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 unified diff | Download patch
OLDNEW
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 "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 9
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Marks an instantaneous event associated with |async_id|. 149 // Marks an instantaneous event associated with |async_id|.
150 void AsyncInstant(const char* label, 150 void AsyncInstant(const char* label,
151 int64_t async_id, 151 int64_t async_id,
152 int64_t micros = OS::GetCurrentMonotonicMicros()); 152 int64_t micros = OS::GetCurrentMonotonicMicros());
153 // Marks the end of an asynchronous operation associated with |async_id|. 153 // Marks the end of an asynchronous operation associated with |async_id|.
154 void AsyncEnd(const char* label, 154 void AsyncEnd(const char* label,
155 int64_t async_id, 155 int64_t async_id,
156 int64_t micros = OS::GetCurrentMonotonicMicros()); 156 int64_t micros = OS::GetCurrentMonotonicMicros());
157 157
158 void DurationBegin(const char* label, 158 void DurationBegin(const char* label,
159 int64_t micros = OS::GetCurrentMonotonicMicros()); 159 int64_t micros = OS::GetCurrentMonotonicMicros(),
160 void DurationEnd(int64_t micros = OS::GetCurrentMonotonicMicros()); 160 int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
161 void DurationEnd(int64_t micros = OS::GetCurrentMonotonicMicros(),
162 int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
163
161 void Instant(const char* label, 164 void Instant(const char* label,
162 int64_t micros = OS::GetCurrentMonotonicMicros()); 165 int64_t micros = OS::GetCurrentMonotonicMicros());
163 166
164 void Duration(const char* label, 167 void Duration(const char* label,
165 int64_t start_micros, 168 int64_t start_micros,
166 int64_t end_micros); 169 int64_t end_micros,
170 int64_t thread_start_micros = -1,
171 int64_t thread_end_micros = -1);
167 172
168 void Begin(const char* label, 173 void Begin(const char* label,
169 int64_t micros = OS::GetCurrentMonotonicMicros()); 174 int64_t micros = OS::GetCurrentMonotonicMicros(),
175 int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
170 176
171 void End(const char* label, 177 void End(const char* label,
172 int64_t micros = OS::GetCurrentMonotonicMicros()); 178 int64_t micros = OS::GetCurrentMonotonicMicros(),
179 int64_t thread_micros = OS::GetCurrentThreadCPUMicros());
173 180
174 void Counter(const char* label, 181 void Counter(const char* label,
175 int64_t micros = OS::GetCurrentMonotonicMicros()); 182 int64_t micros = OS::GetCurrentMonotonicMicros());
176 183
177 void Metadata(const char* label, 184 void Metadata(const char* label,
178 int64_t micros = OS::GetCurrentMonotonicMicros()); 185 int64_t micros = OS::GetCurrentMonotonicMicros());
179 186
180 // Completes this event with pre-serialized JSON. Copies |json|. 187 // Completes this event with pre-serialized JSON. Copies |json|.
181 void CompleteWithPreSerializedJSON(const char* json); 188 void CompleteWithPreSerializedJSON(const char* json);
182 189
(...skipping 14 matching lines...) Expand all
197 void Complete(); 204 void Complete();
198 205
199 EventType event_type() const { 206 EventType event_type() const {
200 return EventTypeField::decode(state_); 207 return EventTypeField::decode(state_);
201 } 208 }
202 209
203 bool IsFinishedDuration() const { 210 bool IsFinishedDuration() const {
204 return (event_type() == kDuration) && (timestamp1_ > timestamp0_); 211 return (event_type() == kDuration) && (timestamp1_ > timestamp0_);
205 } 212 }
206 213
214 bool HasThreadCPUTime() const;
215 int64_t ThreadCPUTimeDuration() const;
216 int64_t ThreadCPUTimeOrigin() const;
217
207 int64_t TimeOrigin() const; 218 int64_t TimeOrigin() const;
208 int64_t AsyncId() const; 219 int64_t AsyncId() const;
209 int64_t TimeDuration() const; 220 int64_t TimeDuration() const;
210 int64_t TimeEnd() const { 221 int64_t TimeEnd() const {
211 ASSERT(IsFinishedDuration()); 222 ASSERT(IsFinishedDuration());
212 return timestamp1_; 223 return timestamp1_;
213 } 224 }
214 225
215 void PrintJSON(JSONStream* stream) const; 226 void PrintJSON(JSONStream* stream) const;
216 227
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 315
305 void set_timestamp0(int64_t value) { 316 void set_timestamp0(int64_t value) {
306 ASSERT(timestamp0_ == 0); 317 ASSERT(timestamp0_ == 0);
307 timestamp0_ = value; 318 timestamp0_ = value;
308 } 319 }
309 void set_timestamp1(int64_t value) { 320 void set_timestamp1(int64_t value) {
310 ASSERT(timestamp1_ == 0); 321 ASSERT(timestamp1_ == 0);
311 timestamp1_ = value; 322 timestamp1_ = value;
312 } 323 }
313 324
325 void set_thread_timestamp0(int64_t value) {
326 ASSERT(thread_timestamp0_ == -1);
327 thread_timestamp0_ = value;
328 }
329
330 void set_thread_timestamp1(int64_t value) {
331 ASSERT(thread_timestamp1_ == -1);
332 thread_timestamp1_ = value;
333 }
334
314 bool pre_serialized_json() const { 335 bool pre_serialized_json() const {
315 return PreSerializedJSON::decode(state_); 336 return PreSerializedJSON::decode(state_);
316 } 337 }
317 338
318 void set_pre_serialized_json(bool pre_serialized_json) { 339 void set_pre_serialized_json(bool pre_serialized_json) {
319 state_ = PreSerializedJSON::update(pre_serialized_json, state_); 340 state_ = PreSerializedJSON::update(pre_serialized_json, state_);
320 } 341 }
321 342
322 bool owns_label() const { 343 bool owns_label() const {
323 return OwnsLabelBit::decode(state_); 344 return OwnsLabelBit::decode(state_);
324 } 345 }
325 346
326 enum StateBits { 347 enum StateBits {
327 kEventTypeBit = 0, // reserve 4 bits for type. 348 kEventTypeBit = 0, // reserve 4 bits for type.
328 kPreSerializedJSON = 4, 349 kPreSerializedJSON = 4,
329 kOwnsLabelBit = 5, 350 kOwnsLabelBit = 5,
330 kNextBit = 6, 351 kNextBit = 6,
331 }; 352 };
332 353
333 class EventTypeField : public BitField<uword, EventType, kEventTypeBit, 4> {}; 354 class EventTypeField : public BitField<uword, EventType, kEventTypeBit, 4> {};
334 class PreSerializedJSON : 355 class PreSerializedJSON :
335 public BitField<uword, bool, kPreSerializedJSON, 1> {}; 356 public BitField<uword, bool, kPreSerializedJSON, 1> {};
336 class OwnsLabelBit : public BitField<uword, bool, kOwnsLabelBit, 1> {}; 357 class OwnsLabelBit : public BitField<uword, bool, kOwnsLabelBit, 1> {};
337 358
338 int64_t timestamp0_; 359 int64_t timestamp0_;
339 int64_t timestamp1_; 360 int64_t timestamp1_;
361 int64_t thread_timestamp0_;
362 int64_t thread_timestamp1_;
340 TimelineEventArgument* arguments_; 363 TimelineEventArgument* arguments_;
341 intptr_t arguments_length_; 364 intptr_t arguments_length_;
342 uword state_; 365 uword state_;
343 const char* label_; 366 const char* label_;
344 const char* category_; 367 const char* category_;
345 ThreadId thread_; 368 ThreadId thread_;
346 Dart_Port isolate_id_; 369 Dart_Port isolate_id_;
347 370
348 friend class TimelineEventRecorder; 371 friend class TimelineEventRecorder;
349 friend class TimelineEventEndlessRecorder; 372 friend class TimelineEventEndlessRecorder;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 const char* label); 502 const char* label);
480 503
481 TimelineDurationScope(Thread* thread, 504 TimelineDurationScope(Thread* thread,
482 TimelineStream* stream, 505 TimelineStream* stream,
483 const char* label); 506 const char* label);
484 507
485 ~TimelineDurationScope(); 508 ~TimelineDurationScope();
486 509
487 private: 510 private:
488 int64_t timestamp_; 511 int64_t timestamp_;
512 int64_t thread_timestamp_;
489 513
490 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope); 514 DISALLOW_COPY_AND_ASSIGN(TimelineDurationScope);
491 }; 515 };
492 516
493 517
494 class TimelineBeginEndScope : public TimelineEventScope { 518 class TimelineBeginEndScope : public TimelineEventScope {
495 public: 519 public:
496 TimelineBeginEndScope(TimelineStream* stream, 520 TimelineBeginEndScope(TimelineStream* stream,
497 const char* label); 521 const char* label);
498 522
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 872
849 private: 873 private:
850 TimelineEventBlock* current_; 874 TimelineEventBlock* current_;
851 TimelineEventRecorder* recorder_; 875 TimelineEventRecorder* recorder_;
852 }; 876 };
853 877
854 878
855 } // namespace dart 879 } // namespace dart
856 880
857 #endif // VM_TIMELINE_H_ 881 #endif // VM_TIMELINE_H_
OLDNEW
« runtime/vm/os_macos.cc ('K') | « runtime/vm/os_win.cc ('k') | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698