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

Unified Diff: runtime/lib/timeline.cc

Issue 1966833002: Dart Timeline improvements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/timeline.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/timeline.cc
diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc
index df36a2517b8598e0bc2cdf3429274b8fe645f28c..d8bef457202901fbf7c4ac1b5f7bc84760635924 100644
--- a/runtime/lib/timeline.cc
+++ b/runtime/lib/timeline.cc
@@ -37,6 +37,11 @@ DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0) {
}
+DEFINE_NATIVE_ENTRY(Timeline_getThreadCpuClock, 0) {
+ return Integer::New(OS::GetCurrentThreadCPUMicros(), Heap::kNew);
+}
+
+
DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 6) {
if (!FLAG_support_timeline) {
return Object::null();
@@ -108,7 +113,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
return Object::null();
}
GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0));
- GET_NON_NULL_NATIVE_ARGUMENT(Integer, end, arguments->NativeArgAt(1));
+ GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2));
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(3));
GET_NON_NULL_NATIVE_ARGUMENT(String, args, arguments->NativeArgAt(4));
@@ -124,24 +129,49 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 5) {
return Object::null();
}
- int64_t duration = end.AsInt64Value() - start.AsInt64Value();
+ const int64_t end = OS::GetCurrentMonotonicMicros();
+ const int64_t end_cpu = OS::GetCurrentThreadCPUMicros();
+ const int64_t duration = end - start.AsInt64Value();
+ const int64_t duration_cpu = end_cpu - start_cpu.AsInt64Value();
int64_t pid = OS::ProcessId();
OSThread* os_thread = thread->os_thread();
ASSERT(os_thread != NULL);
int64_t tid = OSThread::ThreadIdToIntPtr(os_thread->trace_id());
- char* json = OS::SCreate(zone,
- "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 ","
- "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}",
- name.ToCString(),
- category.ToCString(),
- tid,
- pid,
- start.AsInt64Value(),
- duration,
- args.ToCString());
+ char* json = NULL;
+
+ if ((start_cpu.AsInt64Value() != -1) && (end_cpu != -1)) {
+ json = OS::SCreate(zone,
+ "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 ","
+ "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ","
+ "\"tdur\":%" Pd64 ",\"args\":%s}",
+ name.ToCString(),
+ category.ToCString(),
+ tid,
+ pid,
+ start.AsInt64Value(),
+ duration,
+ duration_cpu,
+ args.ToCString());
+ } else {
+ json = OS::SCreate(zone,
+ "{\"name\":\"%s\",\"cat\":\"%s\",\"tid\":%" Pd64 ",\"pid\":%" Pd64 ","
+ "\"ts\":%" Pd64 ",\"ph\":\"X\",\"dur\":%" Pd64 ",\"args\":%s}",
+ name.ToCString(),
+ category.ToCString(),
+ tid,
+ pid,
+ start.AsInt64Value(),
+ duration,
+ args.ToCString());
+ }
+ ASSERT(json != NULL);
- event->Duration("", start.AsInt64Value(), end.AsInt64Value());
+ event->Duration("",
+ start.AsInt64Value(),
+ end,
+ start_cpu.AsInt64Value(),
+ end_cpu);
// json was allocated in the zone and a copy will be stored in event.
event->CompleteWithPreSerializedJSON(json);
« no previous file with comments | « no previous file | runtime/lib/timeline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698