| 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 RUNTIME_VM_TIMELINE_ANALYSIS_H_ | 5 #ifndef RUNTIME_VM_TIMELINE_ANALYSIS_H_ |
| 6 #define RUNTIME_VM_TIMELINE_ANALYSIS_H_ | 6 #define RUNTIME_VM_TIMELINE_ANALYSIS_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/timeline.h" | 9 #include "vm/timeline.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class TimelineAnalysisThread : public ZoneAllocated { | 13 class TimelineAnalysisThread : public ZoneAllocated { |
| 14 public: | 14 public: |
| 15 explicit TimelineAnalysisThread(ThreadId id); | 15 explicit TimelineAnalysisThread(ThreadId id); |
| 16 ~TimelineAnalysisThread(); | 16 ~TimelineAnalysisThread(); |
| 17 | 17 |
| 18 ThreadId id() const { | 18 ThreadId id() const { return id_; } |
| 19 return id_; | |
| 20 } | |
| 21 | 19 |
| 22 intptr_t NumBlocks() const { | 20 intptr_t NumBlocks() const { return blocks_.length(); } |
| 23 return blocks_.length(); | |
| 24 } | |
| 25 | 21 |
| 26 TimelineEventBlock* At(intptr_t i) const { | 22 TimelineEventBlock* At(intptr_t i) const { return blocks_.At(i); } |
| 27 return blocks_.At(i); | |
| 28 } | |
| 29 | 23 |
| 30 private: | 24 private: |
| 31 void AddBlock(TimelineEventBlock* block); | 25 void AddBlock(TimelineEventBlock* block); |
| 32 void Finalize(); | 26 void Finalize(); |
| 33 | 27 |
| 34 const ThreadId id_; | 28 const ThreadId id_; |
| 35 ZoneGrowableArray<TimelineEventBlock*> blocks_; | 29 ZoneGrowableArray<TimelineEventBlock*> blocks_; |
| 36 | 30 |
| 37 friend class TimelineAnalysis; | 31 friend class TimelineAnalysis; |
| 38 }; | 32 }; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 62 // - collecting all ThreadEventBlocks by thread id. | 56 // - collecting all ThreadEventBlocks by thread id. |
| 63 class TimelineAnalysis : public ValueObject { | 57 class TimelineAnalysis : public ValueObject { |
| 64 public: | 58 public: |
| 65 TimelineAnalysis(Zone* zone, | 59 TimelineAnalysis(Zone* zone, |
| 66 Isolate* isolate, | 60 Isolate* isolate, |
| 67 TimelineEventRecorder* recorder); | 61 TimelineEventRecorder* recorder); |
| 68 ~TimelineAnalysis(); | 62 ~TimelineAnalysis(); |
| 69 | 63 |
| 70 void BuildThreads(); | 64 void BuildThreads(); |
| 71 | 65 |
| 72 intptr_t NumThreads() const { | 66 intptr_t NumThreads() const { return threads_.length(); } |
| 73 return threads_.length(); | |
| 74 } | |
| 75 | 67 |
| 76 TimelineAnalysisThread* At(intptr_t i) const { | 68 TimelineAnalysisThread* At(intptr_t i) const { return threads_[i]; } |
| 77 return threads_[i]; | |
| 78 } | |
| 79 | 69 |
| 80 TimelineAnalysisThread* GetThread(ThreadId tid); | 70 TimelineAnalysisThread* GetThread(ThreadId tid); |
| 81 | 71 |
| 82 bool has_error() const { | 72 bool has_error() const { return has_error_; } |
| 83 return has_error_; | |
| 84 } | |
| 85 | 73 |
| 86 const char* error_msg() const { | 74 const char* error_msg() const { return error_msg_; } |
| 87 return error_msg_; | |
| 88 } | |
| 89 | 75 |
| 90 protected: | 76 protected: |
| 91 TimelineAnalysisThread* GetOrAddThread(ThreadId tid); | 77 TimelineAnalysisThread* GetOrAddThread(ThreadId tid); |
| 92 | 78 |
| 93 void DiscoverThreads(); | 79 void DiscoverThreads(); |
| 94 void FinalizeThreads(); | 80 void FinalizeThreads(); |
| 95 | 81 |
| 96 void SetError(const char* format, ...); | 82 void SetError(const char* format, ...); |
| 97 | 83 |
| 98 Zone* zone_; | 84 Zone* zone_; |
| 99 Isolate* isolate_; | 85 Isolate* isolate_; |
| 100 TimelineEventRecorder* recorder_; | 86 TimelineEventRecorder* recorder_; |
| 101 bool has_error_; | 87 bool has_error_; |
| 102 const char* error_msg_; | 88 const char* error_msg_; |
| 103 | 89 |
| 104 ZoneGrowableArray<TimelineAnalysisThread*> threads_; | 90 ZoneGrowableArray<TimelineAnalysisThread*> threads_; |
| 105 }; | 91 }; |
| 106 | 92 |
| 107 | 93 |
| 108 class TimelineLabelPauseInfo : public ZoneAllocated { | 94 class TimelineLabelPauseInfo : public ZoneAllocated { |
| 109 public: | 95 public: |
| 110 explicit TimelineLabelPauseInfo(const char* name); | 96 explicit TimelineLabelPauseInfo(const char* name); |
| 111 | 97 |
| 112 const char* name() const { | 98 const char* name() const { return name_; } |
| 113 return name_; | |
| 114 } | |
| 115 | 99 |
| 116 int64_t inclusive_micros() const { | 100 int64_t inclusive_micros() const { return inclusive_micros_; } |
| 117 return inclusive_micros_; | |
| 118 } | |
| 119 | 101 |
| 120 int64_t exclusive_micros() const { | 102 int64_t exclusive_micros() const { return exclusive_micros_; } |
| 121 return exclusive_micros_; | |
| 122 } | |
| 123 | 103 |
| 124 int64_t max_inclusive_micros() const { | 104 int64_t max_inclusive_micros() const { return max_inclusive_micros_; } |
| 125 return max_inclusive_micros_; | |
| 126 } | |
| 127 | 105 |
| 128 int64_t max_exclusive_micros() const { | 106 int64_t max_exclusive_micros() const { return max_exclusive_micros_; } |
| 129 return max_exclusive_micros_; | |
| 130 } | |
| 131 | 107 |
| 132 private: | 108 private: |
| 133 // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|. | 109 // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|. |
| 134 // Also, may adjust, max_inclusive_micros_. | 110 // Also, may adjust, max_inclusive_micros_. |
| 135 void OnPush(int64_t micros, bool already_on_stack); | 111 void OnPush(int64_t micros, bool already_on_stack); |
| 136 | 112 |
| 137 // Adjusts |exclusive_micros_| by |exclusive_micros|. | 113 // Adjusts |exclusive_micros_| by |exclusive_micros|. |
| 138 // Also, may adjust |max_exclusive_micros_|. | 114 // Also, may adjust |max_exclusive_micros_|. |
| 139 void OnPop(int64_t exclusive_micros); | 115 void OnPop(int64_t exclusive_micros); |
| 140 | 116 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 167 int64_t max_inclusive_micros_; | 143 int64_t max_inclusive_micros_; |
| 168 int64_t max_exclusive_micros_; | 144 int64_t max_exclusive_micros_; |
| 169 | 145 |
| 170 friend class TimelinePauses; | 146 friend class TimelinePauses; |
| 171 friend class TimelinePauseTrace; | 147 friend class TimelinePauseTrace; |
| 172 }; | 148 }; |
| 173 | 149 |
| 174 | 150 |
| 175 class TimelinePauses : public TimelineAnalysis { | 151 class TimelinePauses : public TimelineAnalysis { |
| 176 public: | 152 public: |
| 177 TimelinePauses(Zone* zone, | 153 TimelinePauses(Zone* zone, Isolate* isolate, TimelineEventRecorder* recorder); |
| 178 Isolate* isolate, | |
| 179 TimelineEventRecorder* recorder); | |
| 180 | 154 |
| 181 void Setup(); | 155 void Setup(); |
| 182 | 156 |
| 183 void CalculatePauseTimesForThread(ThreadId tid); | 157 void CalculatePauseTimesForThread(ThreadId tid); |
| 184 | 158 |
| 185 TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const; | 159 TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const; |
| 186 | 160 |
| 187 int64_t InclusiveTime(const char* name) const; | 161 int64_t InclusiveTime(const char* name) const; |
| 188 int64_t ExclusiveTime(const char* name) const; | 162 int64_t ExclusiveTime(const char* name) const; |
| 189 int64_t MaxInclusiveTime(const char* name) const; | 163 int64_t MaxInclusiveTime(const char* name) const; |
| 190 int64_t MaxExclusiveTime(const char* name) const; | 164 int64_t MaxExclusiveTime(const char* name) const; |
| 191 | 165 |
| 192 intptr_t NumPauseInfos() const { | 166 intptr_t NumPauseInfos() const { return labels_.length(); } |
| 193 return labels_.length(); | |
| 194 } | |
| 195 | 167 |
| 196 const TimelineLabelPauseInfo* PauseInfoAt(intptr_t i) const { | 168 const TimelineLabelPauseInfo* PauseInfoAt(intptr_t i) const { |
| 197 return labels_.At(i); | 169 return labels_.At(i); |
| 198 } | 170 } |
| 199 | 171 |
| 200 private: | 172 private: |
| 201 struct StackItem { | 173 struct StackItem { |
| 202 TimelineEvent* event; | 174 TimelineEvent* event; |
| 203 TimelineLabelPauseInfo* pause_info; | 175 TimelineLabelPauseInfo* pause_info; |
| 204 int64_t exclusive_micros; | 176 int64_t exclusive_micros; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 230 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); | 202 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); |
| 231 void Aggregate(const TimelineLabelPauseInfo* thread_pause_info); | 203 void Aggregate(const TimelineLabelPauseInfo* thread_pause_info); |
| 232 void PrintPauseInfo(const TimelineLabelPauseInfo* pause_info); | 204 void PrintPauseInfo(const TimelineLabelPauseInfo* pause_info); |
| 233 | 205 |
| 234 ZoneGrowableArray<TimelineLabelPauseInfo*> isolate_labels_; | 206 ZoneGrowableArray<TimelineLabelPauseInfo*> isolate_labels_; |
| 235 }; | 207 }; |
| 236 | 208 |
| 237 } // namespace dart | 209 } // namespace dart |
| 238 | 210 |
| 239 #endif // RUNTIME_VM_TIMELINE_ANALYSIS_H_ | 211 #endif // RUNTIME_VM_TIMELINE_ANALYSIS_H_ |
| OLD | NEW |