OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
7 #include "include/dart_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "include/dart_tools_api.h" | 9 #include "include/dart_tools_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 9260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9271 | 9271 |
9272 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); | 9272 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); |
9273 | 9273 |
9274 // Check that it is in the output. | 9274 // Check that it is in the output. |
9275 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9275 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); |
9276 JSONStream js; | 9276 JSONStream js; |
9277 recorder->PrintJSON(&js); | 9277 recorder->PrintJSON(&js); |
9278 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); | 9278 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); |
9279 } | 9279 } |
9280 | 9280 |
| 9281 |
| 9282 TEST_CASE(Timeline_Dart_TimelineGetTrace) { |
| 9283 const char* kScriptChars = |
| 9284 "foo() => 'a';\n" |
| 9285 "main() => foo();\n"; |
| 9286 |
| 9287 Dart_Handle lib = |
| 9288 TestCase::LoadTestScript(kScriptChars, NULL); |
| 9289 |
| 9290 const char* buffer = NULL; |
| 9291 intptr_t buffer_length = 0; |
| 9292 bool success = false; |
| 9293 |
| 9294 // Enable recording of all streams. |
| 9295 Dart_TimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL); |
| 9296 |
| 9297 // Invoke main, which will be compiled resulting in a compiler event in |
| 9298 // the timeline. |
| 9299 Dart_Handle result = Dart_Invoke(lib, |
| 9300 NewString("main"), |
| 9301 0, |
| 9302 NULL); |
| 9303 EXPECT_VALID(result); |
| 9304 |
| 9305 // Grab the trace. |
| 9306 success = Dart_TimelineGetTrace(&buffer, &buffer_length); |
| 9307 EXPECT(success); |
| 9308 EXPECT(buffer_length > 0); |
| 9309 EXPECT(buffer != NULL); |
| 9310 // Heartbeat test. |
| 9311 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
| 9312 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
| 9313 EXPECT_SUBSTRING("\"function\":\"main\"", buffer); |
| 9314 } |
| 9315 |
9281 } // namespace dart | 9316 } // namespace dart |
OLD | NEW |