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

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

Issue 864173008: Split profiler.cc into profiler.cc and profiler_service.cc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 #ifndef VM_SCOPE_TIMER_H_
6 #define VM_SCOPE_TIMER_H_
7
8 namespace dart {
9
10 // Simple utility class for timing a block of code.
11 class ScopeTimer : public ValueObject {
12 public:
13 explicit ScopeTimer(const char* name, bool enabled = true)
siva 2015/02/09 23:19:59 constructor has two params, is 'explicit' still ne
Cutch 2015/02/09 23:22:07 Acknowledged.
14 : enabled_(enabled),
15 name_(name) {
16 if (!enabled_) {
17 return;
18 }
19 start_ = OS::GetCurrentTimeMicros();
20 }
21
22 int64_t GetElapsed() const {
23 int64_t end = OS::GetCurrentTimeMicros();
24 ASSERT(end >= start_);
25 return end - start_;
26 }
27
28 ~ScopeTimer() {
29 if (!enabled_) {
30 return;
31 }
32 int64_t elapsed = GetElapsed();
33 OS::Print("%s took %" Pd64 " micros.\n", name_, elapsed);
34 }
35
36 private:
37 const bool enabled_;
38 const char* name_;
39 int64_t start_;
siva 2015/02/09 23:19:59 Missing the boiler plate DISALLOW stuff.
Cutch 2015/02/09 23:22:07 Acknowledged.
40 };
41
42 } // namespace dart
43
44 #endif // VM_SCOPE_TIMER_H_
OLDNEW
« no previous file with comments | « runtime/vm/profiler_service.cc ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698