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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1170503004: Initial Timeline Events (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 890319c4b351ffda756b2a3226999c5214579488..62972a58e5b83ef3c17d66484af0cdd7d7bfc802 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"
@@ -5673,4 +5674,103 @@ DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
Service::RegisterRootEmbedderCallback(name, callback, user_data);
}
+
+DART_EXPORT Dart_Handle Dart_TimelineDuration(const char* label,
+ int64_t start_micros,
+ int64_t end_micros) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (label == NULL) {
+ RETURN_NULL_ERROR(label);
+ }
+ if (start_micros > end_micros) {
+ const char* msg = "%s: start_micros must be <= end_micros";
+ return Api::NewError(msg, CURRENT_FUNC);
+ }
+ TimelineStream* stream = isolate->GetEmbedderStream();
+ ASSERT(stream != NULL);
+ TimelineEvent* event = stream->RecordEvent();
+ if (event != NULL) {
+ event->Duration(stream, label, start_micros, end_micros);
+ }
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_TimelineInstant(const char* label) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (label == NULL) {
+ RETURN_NULL_ERROR(label);
+ }
+ TimelineStream* stream = isolate->GetEmbedderStream();
+ ASSERT(stream != NULL);
+ TimelineEvent* event = stream->RecordEvent();
+ if (event != NULL) {
+ event->Instant(stream, label);
+ }
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_TimelineAsyncBegin(const char* label,
+ int64_t* async_id) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (label == NULL) {
+ RETURN_NULL_ERROR(label);
+ }
+ if (async_id == NULL) {
+ RETURN_NULL_ERROR(async_id);
+ }
+ *async_id = -1;
+ TimelineStream* stream = isolate->GetEmbedderStream();
+ ASSERT(stream != NULL);
+ TimelineEvent* event = stream->RecordEvent();
+ if (event != NULL) {
+ *async_id = event->AsyncBegin(stream, label);
+ }
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_TimelineAsyncInstant(const char* label,
+ int64_t async_id) {
+ if (async_id < 0) {
+ return Api::Success();
+ }
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (label == NULL) {
+ RETURN_NULL_ERROR(label);
+ }
+ TimelineStream* stream = isolate->GetEmbedderStream();
+ ASSERT(stream != NULL);
+ TimelineEvent* event = stream->RecordEvent();
+ if (event != NULL) {
+ event->AsyncInstant(stream, label, async_id);
+ }
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_TimelineAsyncEnd(const char* label,
+ int64_t async_id) {
+ if (async_id < 0) {
+ return Api::Success();
+ }
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (label == NULL) {
+ RETURN_NULL_ERROR(label);
+ }
+ TimelineStream* stream = isolate->GetEmbedderStream();
+ ASSERT(stream != NULL);
+ TimelineEvent* event = stream->RecordEvent();
+ if (event != NULL) {
+ event->AsyncEnd(stream, label, async_id);
+ }
+ return Api::Success();
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698