| 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_ANALYSIS_H_ | 5 #ifndef VM_TIMELINE_ANALYSIS_H_ |
| 6 #define VM_TIMELINE_ANALYSIS_H_ | 6 #define 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 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 inclusive_micros_ += delta_micros; | 143 inclusive_micros_ += delta_micros; |
| 144 ASSERT(inclusive_micros_ >= 0); | 144 ASSERT(inclusive_micros_ >= 0); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Adjust exclusive micros. | 147 // Adjust exclusive micros. |
| 148 void add_exclusive_micros(int64_t delta_micros) { | 148 void add_exclusive_micros(int64_t delta_micros) { |
| 149 exclusive_micros_ += delta_micros; | 149 exclusive_micros_ += delta_micros; |
| 150 ASSERT(exclusive_micros_ >= 0); | 150 ASSERT(exclusive_micros_ >= 0); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void Aggregate(const TimelineLabelPauseInfo* thread_pause_info); |
| 154 |
| 153 const char* name_; | 155 const char* name_; |
| 154 int64_t inclusive_micros_; | 156 int64_t inclusive_micros_; |
| 155 int64_t exclusive_micros_; | 157 int64_t exclusive_micros_; |
| 156 int64_t max_inclusive_micros_; | 158 int64_t max_inclusive_micros_; |
| 157 int64_t max_exclusive_micros_; | 159 int64_t max_exclusive_micros_; |
| 158 | 160 |
| 159 friend class TimelinePauses; | 161 friend class TimelinePauses; |
| 162 friend class TimelinePauseTrace; |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 | 165 |
| 163 class TimelinePauses : public TimelineAnalysis { | 166 class TimelinePauses : public TimelineAnalysis { |
| 164 public: | 167 public: |
| 165 TimelinePauses(Zone* zone, | 168 TimelinePauses(Zone* zone, |
| 166 Isolate* isolate, | 169 Isolate* isolate, |
| 167 TimelineEventRecorder* recorder); | 170 TimelineEventRecorder* recorder); |
| 168 | 171 |
| 169 void Setup(); | 172 void Setup(); |
| 170 | 173 |
| 171 void CalculatePauseTimesForThread(ThreadId tid); | 174 void CalculatePauseTimesForThread(ThreadId tid); |
| 172 | 175 |
| 173 TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const; | 176 TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const; |
| 174 | 177 |
| 175 int64_t InclusiveTime(const char* name) const; | 178 int64_t InclusiveTime(const char* name) const; |
| 176 int64_t ExclusiveTime(const char* name) const; | 179 int64_t ExclusiveTime(const char* name) const; |
| 177 int64_t MaxInclusiveTime(const char* name) const; | 180 int64_t MaxInclusiveTime(const char* name) const; |
| 178 int64_t MaxExclusiveTime(const char* name) const; | 181 int64_t MaxExclusiveTime(const char* name) const; |
| 179 | 182 |
| 183 intptr_t NumPauseInfos() const { |
| 184 return labels_.length(); |
| 185 } |
| 186 |
| 187 const TimelineLabelPauseInfo* PauseInfoAt(intptr_t i) const { |
| 188 return labels_.At(i); |
| 189 } |
| 190 |
| 180 private: | 191 private: |
| 181 struct StackItem { | 192 struct StackItem { |
| 182 TimelineEvent* event; | 193 TimelineEvent* event; |
| 183 TimelineLabelPauseInfo* pause_info; | 194 TimelineLabelPauseInfo* pause_info; |
| 184 int64_t exclusive_micros; | 195 int64_t exclusive_micros; |
| 185 }; | 196 }; |
| 186 | 197 |
| 187 void ProcessThread(TimelineAnalysisThread* thread); | 198 void ProcessThread(TimelineAnalysisThread* thread); |
| 188 bool CheckStack(TimelineEvent* event); | 199 bool CheckStack(TimelineEvent* event); |
| 189 void PopFinished(int64_t start); | 200 void PopFinished(int64_t start); |
| 190 void Push(TimelineEvent* event); | 201 void Push(TimelineEvent* event); |
| 191 bool IsLabelOnStack(const char* label); | 202 bool IsLabelOnStack(const char* label) const; |
| 192 intptr_t StackDepth() const; | 203 intptr_t StackDepth() const; |
| 193 StackItem& GetStackTop(); | 204 StackItem& GetStackTop(); |
| 194 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); | 205 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); |
| 195 | 206 |
| 196 ZoneGrowableArray<StackItem> stack_; | 207 ZoneGrowableArray<StackItem> stack_; |
| 197 ZoneGrowableArray<TimelineLabelPauseInfo*> labels_; | 208 ZoneGrowableArray<TimelineLabelPauseInfo*> labels_; |
| 198 }; | 209 }; |
| 199 | 210 |
| 211 |
| 212 class TimelinePauseTrace : public ValueObject { |
| 213 public: |
| 214 TimelinePauseTrace(); |
| 215 ~TimelinePauseTrace(); |
| 216 |
| 217 void Print(); |
| 218 |
| 219 private: |
| 220 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); |
| 221 void Aggregate(const TimelineLabelPauseInfo* thread_pause_info); |
| 222 void PrintPauseInfo(const TimelineLabelPauseInfo* pause_info); |
| 223 |
| 224 ZoneGrowableArray<TimelineLabelPauseInfo*> isolate_labels_; |
| 225 }; |
| 226 |
| 200 } // namespace dart | 227 } // namespace dart |
| 201 | 228 |
| 202 #endif // VM_TIMELINE_ANALYSIS_H_ | 229 #endif // VM_TIMELINE_ANALYSIS_H_ |
| OLD | NEW |