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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1360813002: Add API to get the VM global timeline (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 92ace20d1cd49c5fa1ce4e22a20441bbdcc05719..39a7f3e1af62cf5e3853a0b7cddc4c51ad1dfba4 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -9483,4 +9483,58 @@ TEST_CASE(Timeline_Dart_TimelineGetTraceGlobalOverride) {
free(data.buffer);
}
+
+UNIT_TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) {
+ const char* buffer = NULL;
+ intptr_t buffer_length = 0;
+ bool success = false;
+
+ // Enable all streams.
+ Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL |
+ DART_TIMELINE_STREAM_VM);
+ {
+ // Create isolate.
+ TestIsolateScope __test_isolate__;
+ Thread* __thread__ = Thread::Current();
+ ASSERT(__thread__->isolate() == __test_isolate__.isolate());
+ StackZone __zone__(__thread__);
+ HandleScope __hs__(__thread__);
+
+ // Load test script.
+ const char* kScriptChars =
+ "foo() => 'a';\n"
+ "main() => foo();\n";
+
+ Dart_Handle lib =
+ TestCase::LoadTestScript(kScriptChars, NULL);
+
+ // Invoke main, which will be compiled resulting in a compiler event in
+ // the timeline.
+ Dart_Handle result = Dart_Invoke(lib,
+ NewString("main"),
+ 0,
+ NULL);
+ EXPECT_VALID(result);
+ }
+
+ // Isolate is shutdown now.
+ // Grab the global trace.
+ AppendData data;
+ success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
+ EXPECT(success);
+ buffer = reinterpret_cast<char*>(data.buffer);
+ buffer_length = data.buffer_length;
+ EXPECT(buffer_length > 0);
+ EXPECT(buffer != NULL);
+
+ // Heartbeat test.
+ EXPECT_SUBSTRING("\"name\":\"InitializeIsolate\"", buffer);
+ EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
+ EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
+ EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
+
+ // Free buffer allocated by AppendStreamConsumer
+ free(data.buffer);
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698