| OLD | NEW |
| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // 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. |
| 130 // It is used as follows: | 130 // It is used as follows: |
| 131 // { | 131 // { |
| 132 // TimerScope timer(FLAG_name_of_flag, timer, isolate); | 132 // TimerScope timer(FLAG_name_of_flag, timer, isolate); |
| 133 // ..... | 133 // ..... |
| 134 // code that needs to be timed. | 134 // code that needs to be timed. |
| 135 // .... | 135 // .... |
| 136 // } | 136 // } |
| 137 class TimerScope : public StackResource { | 137 class TimerScope : public StackResource { |
| 138 public: | 138 public: |
| 139 TimerScope(bool flag, Timer* timer, Thread* thread = NULL) |
| 140 : StackResource(thread), |
| 141 nested_(false), |
| 142 timer_(flag ? timer : NULL) { |
| 143 Init(); |
| 144 } |
| 145 |
| 139 TimerScope(bool flag, Timer* timer, Isolate* isolate = NULL) | 146 TimerScope(bool flag, Timer* timer, Isolate* isolate = NULL) |
| 140 : StackResource(isolate), | 147 : StackResource(isolate), |
| 141 nested_(false), | 148 nested_(false), |
| 142 timer_(flag ? timer : NULL) { | 149 timer_(flag ? timer : NULL) { |
| 150 Init(); |
| 151 } |
| 152 |
| 153 void Init() { |
| 143 if (timer_ != NULL) { | 154 if (timer_ != NULL) { |
| 144 if (!timer_->running()) { | 155 if (!timer_->running()) { |
| 145 timer_->Start(); | 156 timer_->Start(); |
| 146 } else { | 157 } else { |
| 147 nested_ = true; | 158 nested_ = true; |
| 148 } | 159 } |
| 149 } | 160 } |
| 150 } | 161 } |
| 151 ~TimerScope() { | 162 ~TimerScope() { |
| 152 if (timer_ != NULL) { | 163 if (timer_ != NULL) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 TimerScope vm_internal_timer_(true, &(isolate->timer_list().name()), isolate) | 218 TimerScope vm_internal_timer_(true, &(isolate->timer_list().name()), isolate) |
| 208 | 219 |
| 209 #define PAUSETIMERSCOPE(isolate, name) \ | 220 #define PAUSETIMERSCOPE(isolate, name) \ |
| 210 PauseTimerScope vm_internal_timer_(true, \ | 221 PauseTimerScope vm_internal_timer_(true, \ |
| 211 &(isolate->timer_list().name()), \ | 222 &(isolate->timer_list().name()), \ |
| 212 isolate) | 223 isolate) |
| 213 | 224 |
| 214 } // namespace dart | 225 } // namespace dart |
| 215 | 226 |
| 216 #endif // VM_TIMER_H_ | 227 #endif // VM_TIMER_H_ |
| OLD | NEW |