Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
| index 9562941a55c1c60df280fc5fbc503b0682092fa2..88344a7b7ba1514e83556d23835d58c5852370ff 100644 |
| --- a/runtime/vm/dart_api_impl.cc |
| +++ b/runtime/vm/dart_api_impl.cc |
| @@ -36,6 +36,7 @@ |
| #include "vm/stack_frame.h" |
| #include "vm/symbols.h" |
| #include "vm/tags.h" |
| +#include "vm/timeline.h" |
| #include "vm/timer.h" |
| #include "vm/unicode.h" |
| #include "vm/verifier.h" |
| @@ -5612,4 +5613,74 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| } |
| + |
| +DART_EXPORT void Dart_TimelineDuration(const char* label, |
| + int64_t start_micros, |
| + int64_t end_micros) { |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
|
siva
2015/06/12 19:50:34
Normally we do a check of all arguments in the API
Cutch
2015/06/12 23:18:56
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->Duration(stream, label, start_micros, end_micros); |
| + } |
| +} |
| + |
| + |
| +DART_EXPORT void Dart_TimelineInstant(const char* label) { |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
|
siva
2015/06/12 19:50:34
Ditto comment about checking label parameter.
Cutch
2015/06/12 23:18:56
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->Instant(stream, label); |
| + } |
| +} |
| + |
| + |
| +DART_EXPORT int64_t Dart_TimelineAsyncBegin(const char* label) { |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
|
siva
2015/06/12 19:50:34
Ditto.
Cutch
2015/06/12 23:18:56
Done.
|
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + return event->AsyncBegin(stream, label); |
| + } |
| + return -1; |
| +} |
| + |
| + |
| +DART_EXPORT void Dart_TimelineAsyncInstant(const char* label, |
| + int64_t async_id) { |
| + if (async_id < 0) { |
| + return; |
| + } |
|
siva
2015/06/12 19:50:34
Also doesn't async_id have to be a value that you
Cutch
2015/06/12 23:18:56
Not right now. I can start tracking open async ids
|
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->AsyncInstant(stream, label, async_id); |
| + } |
| +} |
| + |
| + |
| +DART_EXPORT void Dart_TimelineAsyncEnd(const char* label, int64_t async_id) { |
| + if (async_id < 0) { |
| + return; |
| + } |
| + Isolate* isolate = Isolate::Current(); |
| + CHECK_ISOLATE(isolate); |
| + TimelineStream* stream = isolate->GetEmbedderStream(); |
| + ASSERT(stream != NULL); |
| + TimelineEvent* event = stream->RecordEvent(); |
| + if (event != NULL) { |
| + event->AsyncEnd(stream, label, async_id); |
| + } |
| +} |
| + |
| } // namespace dart |