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

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

Issue 137483010: Add more timing information in the VM to track time spent is dart code Vs native code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
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 #include "vm/timer.h" 5 #include "vm/timer.h"
6 #include "vm/json_stream.h" 6 #include "vm/json_stream.h"
7 7
8 namespace dart { 8 namespace dart {
9 9
10 // Define timer command line flags. 10 // Define timer command line flags.
11 #define DEFINE_TIMER_FLAG(name, msg) \ 11 #define DEFINE_TIMER_FLAG(name, msg) \
12 DEFINE_FLAG(bool, name, false, ""#name); 12 DEFINE_FLAG(bool, name, false, ""#name);
13 TIMER_LIST(DEFINE_TIMER_FLAG) 13 TIMER_LIST(DEFINE_TIMER_FLAG)
14 #undef DEFINE_TIMER_FLAG 14 #undef DEFINE_TIMER_FLAG
15 DEFINE_FLAG(bool, time_all, false, "Time all functionality"); 15 DEFINE_FLAG(bool, time_all, false, "Time all functionality");
16 16
17 17
18 // Maintains a list of timers per isolate. 18 // Maintains a list of timers per isolate.
19 #define INIT_TIMERS(name, msg) \ 19 #define INIT_TIMERS(name, msg) \
20 name##_((FLAG_##name || FLAG_time_all), msg), 20 name##_((FLAG_##name || FLAG_time_all), msg),
21 TimerList::TimerList() 21 TimerList::TimerList()
22 : TIMER_LIST(INIT_TIMERS) 22 : TIMER_LIST(INIT_TIMERS)
23 padding_(false) { 23 padding_(false) {
24 } 24 }
25 #undef INIT_TIMERS 25 #undef INIT_TIMERS
26 26
27 27
28 #define TIMER_FIELD_REPORT(name, msg) \ 28 #define TIMER_FIELD_REPORT(name, msg) \
29 if (name().report() && name().message() != NULL) { \ 29 if (name().report() && name().message() != NULL) { \
30 OS::Print("%s : %" Pd64 " micros.\n", \ 30 OS::Print("%s : %" Pd64 " micros.\n", \
31 name().message(), \ 31 name().message(), \
32 name().TotalElapsedTime()); \ 32 name().TotalElapsedTime()); \
33 } 33 }
34 void TimerList::ReportTimers() { 34 void TimerList::ReportTimers() {
35 TIMER_LIST(TIMER_FIELD_REPORT); 35 TIMER_LIST(TIMER_FIELD_REPORT);
36 } 36 }
37 #undef TIMER_FIELD_REPORT 37 #undef TIMER_FIELD_REPORT
38 38
39 39
40 #define TIMER_STATE_REPORT(prefix, name) \
41 ASSERT(name().message() != NULL); \
42 OS::Print("%s %s : %s\n", \
43 prefix, name().message(), name().running() ? "on" : "off");
44 void TimerList::ReportTimerState(const char* prefix) {
45 TIMER_STATE_REPORT(prefix, time_native_execution);
46 TIMER_STATE_REPORT(prefix, time_dart_execution);
47 }
48 #undef TIMER_STATE_REPORT
49
50
40 #define JSON_TIMER(name, msg) \ 51 #define JSON_TIMER(name, msg) \
41 { \ 52 { \
42 JSONObject jsobj(&jsarr); \ 53 JSONObject jsobj(&jsarr); \
43 jsobj.AddProperty("name", #name); \ 54 jsobj.AddProperty("name", #name); \
44 double seconds = static_cast<double>(name().TotalElapsedTime()) / \ 55 double seconds = static_cast<double>(name().TotalElapsedTime()) / \
45 static_cast<double>(kMicrosecondsPerSecond); \ 56 static_cast<double>(kMicrosecondsPerSecond); \
46 jsobj.AddProperty("time", seconds); \ 57 jsobj.AddProperty("time", seconds); \
47 } 58 }
48 void TimerList::PrintTimersToJSONProperty(JSONObject* jsobj) { 59 void TimerList::PrintTimersToJSONProperty(JSONObject* jsobj) {
49 JSONArray jsarr(jsobj, "timers"); 60 JSONArray jsarr(jsobj, "timers");
50 TIMER_LIST(JSON_TIMER); 61 TIMER_LIST(JSON_TIMER);
51 } 62 }
52 #undef JSON_TIMER 63 #undef JSON_TIMER
53 64
54 } // namespace dart 65 } // namespace dart
OLDNEW
« runtime/vm/native_arguments.h ('K') | « runtime/vm/timer.h ('k') | runtime/vm/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698