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 21 matching lines...) Expand all Loading... |
32 ASSERT(start_ != 0); | 32 ASSERT(start_ != 0); |
33 ASSERT(running()); | 33 ASSERT(running()); |
34 stop_ = OS::GetCurrentMonotonicMicros(); | 34 stop_ = OS::GetCurrentMonotonicMicros(); |
35 int64_t elapsed = ElapsedMicros(); | 35 int64_t elapsed = ElapsedMicros(); |
36 max_contiguous_ = Utils::Maximum(max_contiguous_, elapsed); | 36 max_contiguous_ = Utils::Maximum(max_contiguous_, elapsed); |
37 // Make increment atomic in case it occurs in parallel with aggregation. | 37 // Make increment atomic in case it occurs in parallel with aggregation. |
38 AtomicOperations::IncrementInt64By(&total_, elapsed); | 38 AtomicOperations::IncrementInt64By(&total_, elapsed); |
39 running_ = false; | 39 running_ = false; |
40 } | 40 } |
41 | 41 |
42 // Get total cummulative elapsed time in micros. | 42 // Get total cumulative elapsed time in micros. |
43 int64_t TotalElapsedTime() const { | 43 int64_t TotalElapsedTime() const { |
44 int64_t result = total_; | 44 int64_t result = total_; |
45 if (running_) { | 45 if (running_) { |
46 int64_t now = OS::GetCurrentMonotonicMicros(); | 46 int64_t now = OS::GetCurrentMonotonicMicros(); |
47 result += (now - start_); | 47 result += (now - start_); |
48 } | 48 } |
49 return result; | 49 return result; |
50 } | 50 } |
51 | 51 |
52 int64_t MaxContiguous() const { | 52 int64_t MaxContiguous() const { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 Timer* const timer_; | 165 Timer* const timer_; |
166 | 166 |
167 DISALLOW_ALLOCATION(); | 167 DISALLOW_ALLOCATION(); |
168 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); | 168 DISALLOW_COPY_AND_ASSIGN(PauseTimerScope); |
169 }; | 169 }; |
170 | 170 |
171 | 171 |
172 } // namespace dart | 172 } // namespace dart |
173 | 173 |
174 #endif // RUNTIME_VM_TIMER_H_ | 174 #endif // RUNTIME_VM_TIMER_H_ |
OLD | NEW |