| 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 RUNTIME_VM_TIMER_H_ | 5 #ifndef RUNTIME_VM_TIMER_H_ |
| 6 #define RUNTIME_VM_TIMER_H_ | 6 #define RUNTIME_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/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int64_t stop_; | 91 int64_t stop_; |
| 92 int64_t total_; | 92 int64_t total_; |
| 93 int64_t max_contiguous_; | 93 int64_t max_contiguous_; |
| 94 bool report_; | 94 bool report_; |
| 95 bool running_; | 95 bool running_; |
| 96 const char* message_; | 96 const char* message_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(Timer); | 98 DISALLOW_COPY_AND_ASSIGN(Timer); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 | |
| 102 // The class TimerScope is used to start and stop a timer within a scope. | 101 // The class TimerScope is used to start and stop a timer within a scope. |
| 103 // It is used as follows: | 102 // It is used as follows: |
| 104 // { | 103 // { |
| 105 // TimerScope timer(FLAG_name_of_flag, timer, isolate); | 104 // TimerScope timer(FLAG_name_of_flag, timer, isolate); |
| 106 // ..... | 105 // ..... |
| 107 // code that needs to be timed. | 106 // code that needs to be timed. |
| 108 // .... | 107 // .... |
| 109 // } | 108 // } |
| 110 class TimerScope : public StackResource { | 109 class TimerScope : public StackResource { |
| 111 public: | 110 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 132 } | 131 } |
| 133 | 132 |
| 134 private: | 133 private: |
| 135 bool nested_; | 134 bool nested_; |
| 136 Timer* const timer_; | 135 Timer* const timer_; |
| 137 | 136 |
| 138 DISALLOW_ALLOCATION(); | 137 DISALLOW_ALLOCATION(); |
| 139 DISALLOW_COPY_AND_ASSIGN(TimerScope); | 138 DISALLOW_COPY_AND_ASSIGN(TimerScope); |
| 140 }; | 139 }; |
| 141 | 140 |
| 142 | |
| 143 class PauseTimerScope : public StackResource { | 141 class PauseTimerScope : public StackResource { |
| 144 public: | 142 public: |
| 145 PauseTimerScope(bool flag, Timer* timer, Thread* thread = NULL) | 143 PauseTimerScope(bool flag, Timer* timer, Thread* thread = NULL) |
| 146 : StackResource(thread), nested_(false), timer_(flag ? timer : NULL) { | 144 : StackResource(thread), nested_(false), timer_(flag ? timer : NULL) { |
| 147 if (timer_) { | 145 if (timer_) { |
| 148 if (timer_->running()) { | 146 if (timer_->running()) { |
| 149 timer_->Stop(); | 147 timer_->Stop(); |
| 150 } else { | 148 } else { |
| 151 nested_ = true; | 149 nested_ = true; |
| 152 } | 150 } |
| 153 } | 151 } |
| 154 } | 152 } |
| 155 ~PauseTimerScope() { | 153 ~PauseTimerScope() { |
| 156 if (timer_) { | 154 if (timer_) { |
| 157 if (!nested_) { | 155 if (!nested_) { |
| 158 timer_->Start(); | 156 timer_->Start(); |
| 159 } | 157 } |
| 160 } | 158 } |
| 161 } | 159 } |
| 162 | 160 |
| 163 private: | 161 private: |
| 164 bool nested_; | 162 bool nested_; |
| 165 Timer* const timer_; | 163 Timer* const timer_; |
| 166 | 164 |
| 167 DISALLOW_ALLOCATION(); | 165 DISALLOW_ALLOCATION(); |
| 168 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); | 166 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); |
| 169 }; | 167 }; |
| 170 | 168 |
| 171 | |
| 172 } // namespace dart | 169 } // namespace dart |
| 173 | 170 |
| 174 #endif // RUNTIME_VM_TIMER_H_ | 171 #endif // RUNTIME_VM_TIMER_H_ |
| OLD | NEW |