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

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

Issue 1127383008: Fix CompilerStats info (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | Annotate | Revision Log
« runtime/vm/isolate.cc ('K') | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_TIMER_H_ 5 #ifndef VM_TIMER_H_
6 #define VM_TIMER_H_ 6 #define VM_TIMER_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void PrintTimersToJSONProperty(JSONObject* jsobj); 118 void PrintTimersToJSONProperty(JSONObject* jsobj);
119 119
120 private: 120 private:
121 #define TIMER_FIELD(name, msg) Timer name##_; 121 #define TIMER_FIELD(name, msg) Timer name##_;
122 TIMER_LIST(TIMER_FIELD) 122 TIMER_LIST(TIMER_FIELD)
123 #undef TIMER_FIELD 123 #undef TIMER_FIELD
124 bool padding_; 124 bool padding_;
125 DISALLOW_COPY_AND_ASSIGN(TimerList); 125 DISALLOW_COPY_AND_ASSIGN(TimerList);
126 }; 126 };
127 127
128
128 // The class TimerScope is used to start and stop a timer within a scope. 129 // The class TimerScope is used to start and stop a timer within a scope.
129 // It is used as follows: 130 // It is used as follows:
130 // { 131 // {
131 // TimerScope timer(FLAG_name_of_flag, timer, isolate); 132 // TimerScope timer(FLAG_name_of_flag, timer, isolate);
132 // ..... 133 // .....
133 // code that needs to be timed. 134 // code that needs to be timed.
134 // .... 135 // ....
135 // } 136 // }
136 class TimerScope : public StackResource { 137 class TimerScope : public StackResource {
137 public: 138 public:
138 TimerScope(bool flag, Timer* timer, Isolate* isolate = NULL) 139 TimerScope(bool flag, Timer* timer, Isolate* isolate = NULL)
139 : StackResource(isolate), flag_(flag), nested_(false), timer_(timer) { 140 : StackResource(isolate),
140 if (flag_) { 141 nested_(false),
142 timer_(flag ? timer : NULL) {
143 if (timer_ != NULL) {
141 if (!timer_->running()) { 144 if (!timer_->running()) {
142 timer_->Start(); 145 timer_->Start();
143 } else { 146 } else {
144 nested_ = true; 147 nested_ = true;
145 } 148 }
146 } 149 }
147 } 150 }
148 ~TimerScope() { 151 ~TimerScope() {
149 if (flag_) { 152 if (timer_ != NULL) {
150 if (!nested_) { 153 if (!nested_) {
151 timer_->Stop(); 154 timer_->Stop();
152 } 155 }
153 } 156 }
154 } 157 }
155 158
156 private: 159 private:
157 const bool flag_;
158 bool nested_; 160 bool nested_;
159 Timer* const timer_; 161 Timer* const timer_;
160 162
161 DISALLOW_ALLOCATION(); 163 DISALLOW_ALLOCATION();
162 DISALLOW_COPY_AND_ASSIGN(TimerScope); 164 DISALLOW_COPY_AND_ASSIGN(TimerScope);
163 }; 165 };
164 166
165 167
166 class PauseTimerScope : public StackResource { 168 class PauseTimerScope : public StackResource {
167 public: 169 public:
168 PauseTimerScope(bool flag, Timer* timer, Isolate* isolate = NULL) 170 PauseTimerScope(bool flag, Timer* timer, Isolate* isolate = NULL)
169 : StackResource(isolate), flag_(flag), nested_(false), timer_(timer) { 171 : StackResource(isolate),
170 if (flag_) { 172 nested_(false),
173 timer_(flag ? timer : NULL) {
174 if (timer_) {
171 if (timer_->running()) { 175 if (timer_->running()) {
172 timer_->Stop(); 176 timer_->Stop();
173 } else { 177 } else {
174 nested_ = true; 178 nested_ = true;
175 } 179 }
176 } 180 }
177 } 181 }
178 ~PauseTimerScope() { 182 ~PauseTimerScope() {
179 if (flag_) { 183 if (timer_) {
180 if (!nested_) { 184 if (!nested_) {
181 timer_->Start(); 185 timer_->Start();
182 } 186 }
183 } 187 }
184 } 188 }
185 189
186 private: 190 private:
187 const bool flag_;
188 bool nested_; 191 bool nested_;
189 Timer* const timer_; 192 Timer* const timer_;
190 193
191 DISALLOW_ALLOCATION(); 194 DISALLOW_ALLOCATION();
192 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); 195 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope);
193 }; 196 };
194 197
195 198
196 // Macros to deal with named timers in the isolate. 199 // Macros to deal with named timers in the isolate.
197 #define START_TIMER(isolate, name) \ 200 #define START_TIMER(isolate, name) \
198 isolate->timer_list().name().Start(); 201 isolate->timer_list().name().Start();
199 202
200 #define STOP_TIMER(isolate, name) \ 203 #define STOP_TIMER(isolate, name) \
201 isolate->timer_list().name().Stop(); 204 isolate->timer_list().name().Stop();
202 205
203 #define TIMERSCOPE(isolate, name) \ 206 #define TIMERSCOPE(isolate, name) \
204 TimerScope vm_internal_timer_(true, &(isolate->timer_list().name()), isolate) 207 TimerScope vm_internal_timer_(true, &(isolate->timer_list().name()), isolate)
205 208
206 #define PAUSETIMERSCOPE(isolate, name) \ 209 #define PAUSETIMERSCOPE(isolate, name) \
207 PauseTimerScope vm_internal_timer_(true, \ 210 PauseTimerScope vm_internal_timer_(true, \
208 &(isolate->timer_list().name()), \ 211 &(isolate->timer_list().name()), \
209 isolate) 212 isolate)
210 213
211 } // namespace dart 214 } // namespace dart
212 215
213 #endif // VM_TIMER_H_ 216 #endif // VM_TIMER_H_
OLDNEW
« runtime/vm/isolate.cc ('K') | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698