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

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

Issue 2315353004: Record Timeline to Android Systrace (Closed)
Patch Set: Add TimelineEventSystraceRecorder Created 4 years, 3 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
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | runtime/vm/timeline.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 bool Within(int64_t time_origin_micros, 336 bool Within(int64_t time_origin_micros,
337 int64_t time_extent_micros); 337 int64_t time_extent_micros);
338 338
339 const char* GetSerializedJSON() const; 339 const char* GetSerializedJSON() const;
340 340
341 void set_owns_label(bool owns_label) { 341 void set_owns_label(bool owns_label) {
342 state_ = OwnsLabelBit::update(owns_label, state_); 342 state_ = OwnsLabelBit::update(owns_label, state_);
343 } 343 }
344 344
345 // Returns the number of bytes written into |buffer|.
346 intptr_t PrintSystrace(char* buffer, intptr_t buffer_size);
347
345 private: 348 private:
346 void FreeArguments(); 349 void FreeArguments();
347 350
348 void StreamInit(TimelineStream* stream); 351 void StreamInit(TimelineStream* stream);
349 void Init(EventType event_type, const char* label); 352 void Init(EventType event_type, const char* label);
350 353
351 void set_event_type(EventType event_type) { 354 void set_event_type(EventType event_type) {
352 // We only reserve 4 bits to hold the event type. 355 // We only reserve 4 bits to hold the event type.
353 COMPILE_ASSERT(kNumEventTypes < 16); 356 COMPILE_ASSERT(kNumEventTypes < 16);
354 state_ = EventTypeField::update(event_type, state_); 357 state_ = EventTypeField::update(event_type, state_);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 uword state_; 409 uword state_;
407 const char* label_; 410 const char* label_;
408 const char* category_; 411 const char* category_;
409 ThreadId thread_; 412 ThreadId thread_;
410 Dart_Port isolate_id_; 413 Dart_Port isolate_id_;
411 414
412 friend class TimelineEventRecorder; 415 friend class TimelineEventRecorder;
413 friend class TimelineEventEndlessRecorder; 416 friend class TimelineEventEndlessRecorder;
414 friend class TimelineEventRingRecorder; 417 friend class TimelineEventRingRecorder;
415 friend class TimelineEventStartupRecorder; 418 friend class TimelineEventStartupRecorder;
419 friend class TimelineEventSystraceRecorder;
416 friend class TimelineStream; 420 friend class TimelineStream;
417 friend class TimelineTestHelper; 421 friend class TimelineTestHelper;
418 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); 422 DISALLOW_COPY_AND_ASSIGN(TimelineEvent);
419 }; 423 };
420 424
421 425
422 #ifndef PRODUCT 426 #ifndef PRODUCT
423 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ 427 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \
424 TimelineDurationScope tds(thread, \ 428 TimelineDurationScope tds(thread, \
425 Timeline::GetCompilerStream(), \ 429 Timeline::GetCompilerStream(), \
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 bool in_use_; 619 bool in_use_;
616 620
617 void Open(); 621 void Open();
618 void Finish(); 622 void Finish();
619 623
620 friend class Thread; 624 friend class Thread;
621 friend class TimelineEventRecorder; 625 friend class TimelineEventRecorder;
622 friend class TimelineEventEndlessRecorder; 626 friend class TimelineEventEndlessRecorder;
623 friend class TimelineEventRingRecorder; 627 friend class TimelineEventRingRecorder;
624 friend class TimelineEventStartupRecorder; 628 friend class TimelineEventStartupRecorder;
629 friend class TimelineEventSystraceRecorder;
625 friend class TimelineTestHelper; 630 friend class TimelineTestHelper;
626 friend class JSONStream; 631 friend class JSONStream;
627 632
628 private: 633 private:
629 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); 634 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock);
630 }; 635 };
631 636
632 637
633 class TimelineEventFilter : public ValueObject { 638 class TimelineEventFilter : public ValueObject {
634 public: 639 public:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 784
780 const char* name() const { 785 const char* name() const {
781 return "Ring"; 786 return "Ring";
782 } 787 }
783 788
784 protected: 789 protected:
785 TimelineEventBlock* GetNewBlockLocked(); 790 TimelineEventBlock* GetNewBlockLocked();
786 }; 791 };
787 792
788 793
794 // A recorder that writes events to Android Systrace. Events are also stored in
795 // a buffer of fixed capacity. When the buffer is full, new events overwrite
796 // old events.
797 class TimelineEventSystraceRecorder
798 : public TimelineEventFixedBufferRecorder {
799 public:
800 explicit TimelineEventSystraceRecorder(intptr_t capacity = kDefaultCapacity);
801
802 ~TimelineEventSystraceRecorder();
803
804 const char* name() const {
805 return "Systrace";
806 }
807
808 protected:
809 TimelineEventBlock* GetNewBlockLocked();
810 void CompleteEvent(TimelineEvent* event);
811
812 int systrace_fd_;
Chinmay 2016/09/08 17:58:11 Should this be private? Along with the usual `DISA
Cutch 2016/09/08 18:06:10 The base class has the decoration.
813 };
814
815
789 // A recorder that stores events in a buffer of fixed capacity. When the buffer 816 // A recorder that stores events in a buffer of fixed capacity. When the buffer
790 // is full, new events are dropped. 817 // is full, new events are dropped.
791 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { 818 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder {
792 public: 819 public:
793 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) 820 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity)
794 : TimelineEventFixedBufferRecorder(capacity) {} 821 : TimelineEventFixedBufferRecorder(capacity) {}
795 ~TimelineEventStartupRecorder() {} 822 ~TimelineEventStartupRecorder() {}
796 823
797 const char* name() const { 824 const char* name() const {
798 return "Startup"; 825 return "Startup";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 908
882 private: 909 private:
883 TimelineEventBlock* current_; 910 TimelineEventBlock* current_;
884 TimelineEventRecorder* recorder_; 911 TimelineEventRecorder* recorder_;
885 }; 912 };
886 913
887 914
888 } // namespace dart 915 } // namespace dart
889 916
890 #endif // VM_TIMELINE_H_ 917 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | runtime/vm/timeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698