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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9465 matching lines...) Expand 10 before | Expand all | Expand 10 after
9476 9476
9477 // Heartbeat test. 9477 // Heartbeat test.
9478 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer); 9478 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9479 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer); 9479 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9480 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer); 9480 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9481 9481
9482 // Free buffer allocated by AppendStreamConsumer 9482 // Free buffer allocated by AppendStreamConsumer
9483 free(data.buffer); 9483 free(data.buffer);
9484 } 9484 }
9485 9485
9486
9487 UNIT_TEST_CASE(Timeline_Dart_GlobalTimelineGetTrace) {
9488 const char* buffer = NULL;
9489 intptr_t buffer_length = 0;
9490 bool success = false;
9491
9492 // Enable all streams.
9493 Dart_GlobalTimelineSetRecordedStreams(DART_TIMELINE_STREAM_ALL |
9494 DART_TIMELINE_STREAM_VM);
9495 {
9496 // Create isolate.
9497 TestIsolateScope __test_isolate__;
9498 Thread* __thread__ = Thread::Current();
9499 ASSERT(__thread__->isolate() == __test_isolate__.isolate());
9500 StackZone __zone__(__thread__);
9501 HandleScope __hs__(__thread__);
9502
9503 // Load test script.
9504 const char* kScriptChars =
9505 "foo() => 'a';\n"
9506 "main() => foo();\n";
9507
9508 Dart_Handle lib =
9509 TestCase::LoadTestScript(kScriptChars, NULL);
9510
9511 // Invoke main, which will be compiled resulting in a compiler event in
9512 // the timeline.
9513 Dart_Handle result = Dart_Invoke(lib,
9514 NewString("main"),
9515 0,
9516 NULL);
9517 EXPECT_VALID(result);
9518 }
9519
9520 // Isolate is shutdown now.
9521 // Grab the global trace.
9522 AppendData data;
9523 success = Dart_GlobalTimelineGetTrace(AppendStreamConsumer, &data);
9524 EXPECT(success);
9525 buffer = reinterpret_cast<char*>(data.buffer);
9526 buffer_length = data.buffer_length;
9527 EXPECT(buffer_length > 0);
9528 EXPECT(buffer != NULL);
9529
9530 // Heartbeat test.
9531 EXPECT_SUBSTRING("\"name\":\"InitializeIsolate\"", buffer);
9532 EXPECT_SUBSTRING("\"cat\":\"Compiler\"", buffer);
9533 EXPECT_SUBSTRING("\"name\":\"CompileFunction\"", buffer);
9534 EXPECT_SUBSTRING("\"function\":\"::_main\"", buffer);
9535
9536 // Free buffer allocated by AppendStreamConsumer
9537 free(data.buffer);
9538 }
9539
9486 } // namespace dart 9540 } // namespace dart
OLDNEW
« 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