| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 int64_t inclusive_micros() const { | 116 int64_t inclusive_micros() const { |
| 117 return inclusive_micros_; | 117 return inclusive_micros_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 int64_t exclusive_micros() const { | 120 int64_t exclusive_micros() const { |
| 121 return exclusive_micros_; | 121 return exclusive_micros_; |
| 122 } | 122 } |
| 123 | 123 |
| 124 int64_t max_duration_micros() const { | 124 int64_t max_inclusive_micros() const { |
| 125 return max_duration_micros_; | 125 return max_inclusive_micros_; |
| 126 } |
| 127 |
| 128 int64_t max_exclusive_micros() const { |
| 129 return max_exclusive_micros_; |
| 126 } | 130 } |
| 127 | 131 |
| 128 private: | 132 private: |
| 129 // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|. | 133 // Adjusts |inclusive_micros_| and |exclusive_micros_| by |micros|. |
| 130 // Also, may adjust, max_duration_micros_. | 134 // Also, may adjust, max_inclusive_micros_. |
| 131 void OnPush(int64_t micros); | 135 void OnPush(int64_t micros, bool already_on_stack); |
| 132 | 136 |
| 133 // Subtracts |micros| from |exclusive_micros_|. | 137 // Adjusts |exclusive_micros_| by |exclusive_micros|. |
| 134 void OnChildPush(int64_t micros); | 138 // Also, may adjust |max_exclusive_micros_|. |
| 139 void OnPop(int64_t exclusive_micros); |
| 135 | 140 |
| 136 // Adjust inclusive micros. | 141 // Adjust inclusive micros. |
| 137 void add_inclusive_micros(int64_t delta_micros) { | 142 void add_inclusive_micros(int64_t delta_micros) { |
| 138 inclusive_micros_ += delta_micros; | 143 inclusive_micros_ += delta_micros; |
| 139 ASSERT(inclusive_micros_ >= 0); | 144 ASSERT(inclusive_micros_ >= 0); |
| 140 } | 145 } |
| 141 | 146 |
| 142 // Adjust exclusive micros. | 147 // Adjust exclusive micros. |
| 143 void add_exclusive_micros(int64_t delta_micros) { | 148 void add_exclusive_micros(int64_t delta_micros) { |
| 144 exclusive_micros_ += delta_micros; | 149 exclusive_micros_ += delta_micros; |
| 145 ASSERT(exclusive_micros_ >= 0); | 150 ASSERT(exclusive_micros_ >= 0); |
| 146 } | 151 } |
| 147 | 152 |
| 148 const char* name_; | 153 const char* name_; |
| 149 int64_t inclusive_micros_; | 154 int64_t inclusive_micros_; |
| 150 int64_t exclusive_micros_; | 155 int64_t exclusive_micros_; |
| 151 int64_t max_duration_micros_; | 156 int64_t max_inclusive_micros_; |
| 157 int64_t max_exclusive_micros_; |
| 152 | 158 |
| 153 friend class TimelinePauses; | 159 friend class TimelinePauses; |
| 154 }; | 160 }; |
| 155 | 161 |
| 156 | 162 |
| 157 class TimelinePauses : public TimelineAnalysis { | 163 class TimelinePauses : public TimelineAnalysis { |
| 158 public: | 164 public: |
| 159 TimelinePauses(Zone* zone, | 165 TimelinePauses(Zone* zone, |
| 160 Isolate* isolate, | 166 Isolate* isolate, |
| 161 TimelineEventRecorder* recorder); | 167 TimelineEventRecorder* recorder); |
| 162 | 168 |
| 163 void Setup(); | 169 void Setup(); |
| 164 | 170 |
| 165 void CalculatePauseTimesForThread(ThreadId tid); | 171 void CalculatePauseTimesForThread(ThreadId tid); |
| 166 | 172 |
| 167 TimelineLabelPauseInfo* GetLabel(const char* name) const; | 173 TimelineLabelPauseInfo* GetLabelPauseInfo(const char* name) const; |
| 168 | 174 |
| 169 int64_t InclusiveTime(const char* name) const; | 175 int64_t InclusiveTime(const char* name) const; |
| 170 int64_t ExclusiveTime(const char* name) const; | 176 int64_t ExclusiveTime(const char* name) const; |
| 171 int64_t MaxDurationTime(const char* name) const; | 177 int64_t MaxInclusiveTime(const char* name) const; |
| 178 int64_t MaxExclusiveTime(const char* name) const; |
| 172 | 179 |
| 173 private: | 180 private: |
| 181 struct StackItem { |
| 182 TimelineEvent* event; |
| 183 TimelineLabelPauseInfo* pause_info; |
| 184 int64_t exclusive_micros; |
| 185 }; |
| 186 |
| 174 void ProcessThread(TimelineAnalysisThread* thread); | 187 void ProcessThread(TimelineAnalysisThread* thread); |
| 175 bool CheckStack(TimelineEvent* event); | 188 bool CheckStack(TimelineEvent* event); |
| 176 void PopFinished(int64_t start); | 189 void PopFinished(int64_t start); |
| 177 void Push(TimelineEvent* event); | 190 void Push(TimelineEvent* event); |
| 178 TimelineLabelPauseInfo* GetTopLabel(); | 191 bool IsLabelOnStack(const char* label); |
| 179 TimelineLabelPauseInfo* GetOrAddLabel(const char* name); | 192 intptr_t StackDepth() const; |
| 193 StackItem& GetStackTop(); |
| 194 TimelineLabelPauseInfo* GetOrAddLabelPauseInfo(const char* name); |
| 180 | 195 |
| 181 ZoneGrowableArray<TimelineEvent*> stack_; | 196 ZoneGrowableArray<StackItem> stack_; |
| 182 ZoneGrowableArray<TimelineLabelPauseInfo*> labels_; | 197 ZoneGrowableArray<TimelineLabelPauseInfo*> labels_; |
| 183 }; | 198 }; |
| 184 | 199 |
| 185 } // namespace dart | 200 } // namespace dart |
| 186 | 201 |
| 187 #endif // VM_TIMELINE_ANALYSIS_H_ | 202 #endif // VM_TIMELINE_ANALYSIS_H_ |
| OLD | NEW |