Index: runtime/vm/timer.h |
=================================================================== |
--- runtime/vm/timer.h (revision 32027) |
+++ runtime/vm/timer.h (working copy) |
@@ -11,12 +11,14 @@ |
namespace dart { |
+class JSONObject; |
+ |
// Timer class allows timing of specific operations in the VM. |
class Timer : public ValueObject { |
public: |
- Timer(bool enabled, const char* message) |
+ Timer(bool report, const char* message) |
: start_(0), stop_(0), total_(0), |
- enabled_(enabled), running_(false), message_(message) {} |
+ report_(report), enabled_(true), running_(false), message_(message) {} |
Cutch
2014/01/28 19:32:51
Enabled is always true and has no setter, so why k
turnidge
2014/01/28 23:18:55
Removed.
|
~Timer() {} |
// Start timer. |
@@ -42,6 +44,10 @@ |
int64_t TotalElapsedTime() const { |
if (enabled_) { |
int64_t result = total_; |
+ if (running_) { |
+ int64_t now = OS::GetCurrentTimeMicros(); |
+ result += (now - start_); |
+ } |
return result; |
} |
return 0; |
@@ -57,6 +63,7 @@ |
} |
// Accessors. |
+ bool report() const { return report_; } |
bool enabled() const { return enabled_; } |
bool running() const { return running_; } |
const char* message() const { return message_; } |
@@ -74,6 +81,7 @@ |
int64_t start_; |
int64_t stop_; |
int64_t total_; |
+ bool report_; |
bool enabled_; |
bool running_; |
const char* message_; |
@@ -83,12 +91,13 @@ |
// List of per isolate timers. |
#define TIMER_LIST(V) \ |
- V(time_script_loading, "Script Loading : ") \ |
- V(time_creating_snapshot, "Snapshot Creation : ") \ |
- V(time_isolate_initialization, "Isolate initialization : ") \ |
- V(time_compilation, "Function compilation : ") \ |
- V(time_bootstrap, "Bootstrap of core classes : ") \ |
- V(time_total_runtime, "Total runtime for isolate : ") \ |
+ V(time_script_loading, "Script Loading") \ |
+ V(time_creating_snapshot, "Snapshot Creation") \ |
+ V(time_isolate_initialization, "Isolate initialization") \ |
+ V(time_compilation, "Function compilation") \ |
+ V(time_bootstrap, "Bootstrap of core classes") \ |
+ V(time_dart_execution, "Dart execution") \ |
+ V(time_total_runtime, "Total runtime for isolate") \ |
// Declare command line flags for the timers. |
#define DECLARE_TIMER_FLAG(name, msg) \ |
@@ -111,6 +120,8 @@ |
void ReportTimers(); |
+ void PrintTimersToJSONProperty(JSONObject* jsobj); |
+ |
private: |
#define TIMER_FIELD(name, msg) Timer name##_; |
TIMER_LIST(TIMER_FIELD) |
@@ -121,13 +132,10 @@ |
// Timer Usage. |
#define START_TIMER(name) \ |
- if (FLAG_##name || FLAG_time_all) { \ |
- Isolate::Current()->timer_list().name().Start(); \ |
- } |
+ Isolate::Current()->timer_list().name().Start(); |
+ |
#define STOP_TIMER(name) \ |
- if (FLAG_##name || FLAG_time_all) { \ |
- Isolate::Current()->timer_list().name().Stop(); \ |
- } |
+ Isolate::Current()->timer_list().name().Stop(); |
// The class TimerScope is used to start and stop a timer within a scope. |
@@ -143,7 +151,7 @@ |
public: |
TimerScope(bool flag, Timer* timer, BaseIsolate* isolate = NULL) |
: StackResource(isolate), flag_(flag), nested_(false), timer_(timer) { |
- if (flag_) { |
+ if (flag_ || FLAG_time_all) { |
if (!timer_->running()) { |
timer_->Start(); |
} else { |
@@ -167,7 +175,7 @@ |
}; |
#define TIMERSCOPE(name) \ |
- TimerScope vm_internal_timer_((FLAG_##name || FLAG_time_all), \ |
+ TimerScope vm_internal_timer_(true, \ |
Cutch
2014/01/28 19:32:51
Perhaps we to respect FLAG_enable_vm_service ?
turnidge
2014/01/28 23:18:55
That flag is in bin/main.cc -- not available.
|
&(Isolate::Current()->timer_list().name())) |
} // namespace dart |