| 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 9220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9231 | 9231 |
| 9232 TEST_CASE(Timeline_Dart_TimelineDuration) { | 9232 TEST_CASE(Timeline_Dart_TimelineDuration) { |
| 9233 Isolate* isolate = Isolate::Current(); | 9233 Isolate* isolate = Isolate::Current(); |
| 9234 // Grab embedder stream. | 9234 // Grab embedder stream. |
| 9235 TimelineStream* stream = isolate->GetEmbedderStream(); | 9235 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 9236 // Make sure it is enabled. | 9236 // Make sure it is enabled. |
| 9237 stream->set_enabled(true); | 9237 stream->set_enabled(true); |
| 9238 // Add a duration event. | 9238 // Add a duration event. |
| 9239 Dart_TimelineDuration("testDurationEvent", 0, 1); | 9239 Dart_TimelineDuration("testDurationEvent", 0, 1); |
| 9240 // Check that it is in the output. | 9240 // Check that it is in the output. |
| 9241 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9241 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 9242 JSONStream js; | 9242 JSONStream js; |
| 9243 recorder->PrintJSON(&js); | 9243 TimelineEventFilter filter; |
| 9244 recorder->PrintJSON(&js, &filter); |
| 9244 EXPECT_SUBSTRING("testDurationEvent", js.ToCString()); | 9245 EXPECT_SUBSTRING("testDurationEvent", js.ToCString()); |
| 9245 } | 9246 } |
| 9246 | 9247 |
| 9247 | 9248 |
| 9248 TEST_CASE(Timeline_Dart_TimelineInstant) { | 9249 TEST_CASE(Timeline_Dart_TimelineInstant) { |
| 9249 Isolate* isolate = Isolate::Current(); | 9250 Isolate* isolate = Isolate::Current(); |
| 9250 // Grab embedder stream. | 9251 // Grab embedder stream. |
| 9251 TimelineStream* stream = isolate->GetEmbedderStream(); | 9252 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 9252 // Make sure it is enabled. | 9253 // Make sure it is enabled. |
| 9253 stream->set_enabled(true); | 9254 stream->set_enabled(true); |
| 9254 Dart_TimelineInstant("testInstantEvent"); | 9255 Dart_TimelineInstant("testInstantEvent"); |
| 9255 // Check that it is in the output. | 9256 // Check that it is in the output. |
| 9256 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9257 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 9257 JSONStream js; | 9258 JSONStream js; |
| 9258 recorder->PrintJSON(&js); | 9259 TimelineEventFilter filter; |
| 9260 recorder->PrintJSON(&js, &filter); |
| 9259 EXPECT_SUBSTRING("testInstantEvent", js.ToCString()); | 9261 EXPECT_SUBSTRING("testInstantEvent", js.ToCString()); |
| 9260 } | 9262 } |
| 9261 | 9263 |
| 9262 | 9264 |
| 9263 TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) { | 9265 TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) { |
| 9264 Isolate* isolate = Isolate::Current(); | 9266 Isolate* isolate = Isolate::Current(); |
| 9265 // Grab embedder stream. | 9267 // Grab embedder stream. |
| 9266 TimelineStream* stream = isolate->GetEmbedderStream(); | 9268 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 9267 // Make sure it is disabled. | 9269 // Make sure it is disabled. |
| 9268 stream->set_enabled(false); | 9270 stream->set_enabled(false); |
| 9269 int64_t async_id = -1; | 9271 int64_t async_id = -1; |
| 9270 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); | 9272 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); |
| 9271 // Expect that the |async_id| is negative because the stream is disabled. | 9273 // Expect that the |async_id| is negative because the stream is disabled. |
| 9272 EXPECT(async_id < 0); | 9274 EXPECT(async_id < 0); |
| 9273 // Call Dart_TimelineAsyncEnd with a negative async_id. | 9275 // Call Dart_TimelineAsyncEnd with a negative async_id. |
| 9274 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); | 9276 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); |
| 9275 // Check that testAsync is not in the output. | 9277 // Check that testAsync is not in the output. |
| 9276 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9278 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 9277 JSONStream js; | 9279 JSONStream js; |
| 9278 recorder->PrintJSON(&js); | 9280 TimelineEventFilter filter; |
| 9281 recorder->PrintJSON(&js, &filter); |
| 9279 EXPECT_NOTSUBSTRING("testAsyncEvent", js.ToCString()); | 9282 EXPECT_NOTSUBSTRING("testAsyncEvent", js.ToCString()); |
| 9280 } | 9283 } |
| 9281 | 9284 |
| 9282 | 9285 |
| 9283 TEST_CASE(Timeline_Dart_TimelineAsync) { | 9286 TEST_CASE(Timeline_Dart_TimelineAsync) { |
| 9284 Isolate* isolate = Isolate::Current(); | 9287 Isolate* isolate = Isolate::Current(); |
| 9285 // Grab embedder stream. | 9288 // Grab embedder stream. |
| 9286 TimelineStream* stream = isolate->GetEmbedderStream(); | 9289 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 9287 // Make sure it is enabled. | 9290 // Make sure it is enabled. |
| 9288 stream->set_enabled(true); | 9291 stream->set_enabled(true); |
| 9289 int64_t async_id = -1; | 9292 int64_t async_id = -1; |
| 9290 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); | 9293 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); |
| 9291 // Expect that the |async_id| is >= 0. | 9294 // Expect that the |async_id| is >= 0. |
| 9292 EXPECT(async_id >= 0); | 9295 EXPECT(async_id >= 0); |
| 9293 | 9296 |
| 9294 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); | 9297 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); |
| 9295 | 9298 |
| 9296 // Check that it is in the output. | 9299 // Check that it is in the output. |
| 9297 TimelineEventRecorder* recorder = isolate->timeline_event_recorder(); | 9300 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 9298 JSONStream js; | 9301 JSONStream js; |
| 9299 recorder->PrintJSON(&js); | 9302 TimelineEventFilter filter; |
| 9303 recorder->PrintJSON(&js, &filter); |
| 9300 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); | 9304 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); |
| 9301 } | 9305 } |
| 9302 | 9306 |
| 9303 | 9307 |
| 9304 struct AppendData { | 9308 struct AppendData { |
| 9305 uint8_t* buffer; | 9309 uint8_t* buffer; |
| 9306 intptr_t buffer_length; | 9310 intptr_t buffer_length; |
| 9307 }; | 9311 }; |
| 9308 | 9312 |
| 9309 | 9313 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9363 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); | 9367 success = Dart_TimelineGetTrace(AppendStreamConsumer, &data); |
| 9364 EXPECT(success); | 9368 EXPECT(success); |
| 9365 buffer = reinterpret_cast<char*>(data.buffer); | 9369 buffer = reinterpret_cast<char*>(data.buffer); |
| 9366 buffer_length = data.buffer_length; | 9370 buffer_length = data.buffer_length; |
| 9367 EXPECT(buffer_length > 0); | 9371 EXPECT(buffer_length > 0); |
| 9368 EXPECT(buffer != NULL); | 9372 EXPECT(buffer != NULL); |
| 9369 | 9373 |
| 9370 // Heartbeat test. | 9374 // Heartbeat test. |
| 9371 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); | 9375 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); |
| 9372 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); | 9376 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); |
| 9373 EXPECT_SUBSTRING("\"function\":\"main\"", buffer); | 9377 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); |
| 9374 | 9378 |
| 9375 // Free buffer allocated by AppendStreamConsumer | 9379 // Free buffer allocated by AppendStreamConsumer |
| 9376 free(data.buffer); | 9380 free(data.buffer); |
| 9377 } | 9381 } |
| 9378 | 9382 |
| 9379 } // namespace dart | 9383 } // namespace dart |
| OLD | NEW |