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

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

Issue 10389023: Fixed compilation time measurement, restructure some code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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/object.cc ('K') | « runtime/vm/opt_code_generator_ia32.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 "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 20 matching lines...) Expand all
31 void Stop() { 31 void Stop() {
32 if (enabled_) { 32 if (enabled_) {
33 ASSERT(start_ != 0); 33 ASSERT(start_ != 0);
34 ASSERT(running()); 34 ASSERT(running());
35 stop_ = OS::GetCurrentTimeMicros(); 35 stop_ = OS::GetCurrentTimeMicros();
36 total_ += ElapsedMicros(); 36 total_ += ElapsedMicros();
37 running_ = false; 37 running_ = false;
38 } 38 }
39 } 39 }
40 40
41 // Get total cummulative elapsed time in micros and reset the counters. 41 // Get total cummulative elapsed time in micros and reset the counters.
hausner 2012/05/08 21:41:01 Please adjust the comment. I think this was origin
srdjan 2012/05/08 21:51:31 Done.
42 int64_t TotalElapsedTime() { 42 int64_t TotalElapsedTime() const {
43 if (enabled_) { 43 if (enabled_) {
44 int64_t result = total_; 44 int64_t result = total_;
45 Reset();
46 return result; 45 return result;
47 } 46 }
48 return 0; 47 return 0;
49 } 48 }
50 49
51 // Accessors. 50 // Accessors.
52 bool enabled() const { return enabled_; } 51 bool enabled() const { return enabled_; }
53 bool running() const { return running_; } 52 bool running() const { return running_; }
54 const char* message() const { return message_; } 53 const char* message() const { return message_; }
55 54
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 132
134 // The class TimerScope is used to start and stop a timer within a scope. 133 // The class TimerScope is used to start and stop a timer within a scope.
135 // It is used as follows: 134 // It is used as follows:
136 // { 135 // {
137 // TIMERSCOPE(name_of_timer); 136 // TIMERSCOPE(name_of_timer);
138 // .... 137 // ....
139 // ..... 138 // .....
140 // code that needs to be timed. 139 // code that needs to be timed.
141 // .... 140 // ....
142 // } 141 // }
143 class TimerScope : public ValueObject { 142 class TimerScope : public StackResource {
144 public: 143 public:
145 TimerScope(bool flag, Timer* timer) 144 TimerScope(bool flag, Timer* timer, BaseIsolate* isolate = NULL)
146 : flag_(flag), nested_(false), timer_(timer) { 145 : StackResource(isolate), flag_(flag), nested_(false), timer_(timer) {
147 if (flag_) { 146 if (flag_) {
148 if (!timer_->running()) { 147 if (!timer_->running()) {
149 timer_->Start(); 148 timer_->Start();
150 } else { 149 } else {
151 nested_ = true; 150 nested_ = true;
152 } 151 }
153 } 152 }
154 } 153 }
155 ~TimerScope() { 154 ~TimerScope() {
156 if (flag_) { 155 if (flag_) {
(...skipping 10 matching lines...) Expand all
167 DISALLOW_COPY_AND_ASSIGN(TimerScope); 166 DISALLOW_COPY_AND_ASSIGN(TimerScope);
168 }; 167 };
169 168
170 #define TIMERSCOPE(name) \ 169 #define TIMERSCOPE(name) \
171 TimerScope vm_internal_timer_((FLAG_##name || FLAG_time_all), \ 170 TimerScope vm_internal_timer_((FLAG_##name || FLAG_time_all), \
172 &(Isolate::Current()->timer_list().name())) 171 &(Isolate::Current()->timer_list().name()))
173 172
174 } // namespace dart 173 } // namespace dart
175 174
176 #endif // VM_TIMER_H_ 175 #endif // VM_TIMER_H_
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/opt_code_generator_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698