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

Unified Diff: runtime/observatory/tests/service/get_allocation_samples_test.dart

Issue 1231603008: Expose allocation tracing over service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/observatory/lib/src/service/object.dart ('k') | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/get_allocation_samples_test.dart
diff --git a/runtime/observatory/tests/service/get_allocation_samples_test.dart b/runtime/observatory/tests/service/get_allocation_samples_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b70d1211cd509685ccde9081d442793d989c151a
--- /dev/null
+++ b/runtime/observatory/tests/service/get_allocation_samples_test.dart
@@ -0,0 +1,85 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--compile_all --error_on_bad_type --error_on_bad_override
+
+import 'dart:developer';
+import 'package:observatory/service_io.dart';
+import 'package:observatory/cpu_profile.dart';
+import 'package:unittest/unittest.dart';
+
+import 'test_helper.dart';
+
+class Foo {
+ Foo() {
+ print('new Foo');
+ }
+}
+
+void test() {
+ debugger();
+ // Toggled on.
+ debugger();
+ debugger();
+ // Allocation.
+ new Foo();
+ debugger();
+}
+
+var tests = [
+ hasStoppedAtBreakpoint,
+
+ // Initial.
+ (Isolate isolate) async {
+ // Verify initial state of 'Foo'.
+ var fooClass = await getClassFromRootLib(isolate, 'Foo');
+ expect(fooClass, isNotNull);
+ expect(fooClass.name, equals('Foo'));
+ print(fooClass.id);
+ expect(fooClass.traceAllocations, isFalse);
+ await fooClass.setTraceAllocations(true);
+ await fooClass.reload();
+ expect(fooClass.traceAllocations, isTrue);
+ },
+
+ resumeIsolate,
+ hasStoppedAtBreakpoint,
+ // Extra debugger stop, continue to allow the allocation stubs to be switched
+ // over. This is a bug but low priority.
+ resumeIsolate,
+ hasStoppedAtBreakpoint,
+
+ // Allocation profile.
+ (Isolate isolate) async {
+ var fooClass = await getClassFromRootLib(isolate, 'Foo');
+ await fooClass.reload();
+ expect(fooClass.traceAllocations, isTrue);
+ var profileResponse = await fooClass.getAllocationSamples();
+ expect(profileResponse, isNotNull);
+ expect(profileResponse['type'], equals('_CpuProfile'));
+ await fooClass.setTraceAllocations(false);
+ await fooClass.reload();
+ expect(fooClass.traceAllocations, isFalse);
+ CpuProfile cpuProfile = new CpuProfile();
+ cpuProfile.load(isolate, profileResponse);
+ cpuProfile.buildCodeCallerAndCallees();
+ cpuProfile.buildFunctionCallerAndCallees();
+ var tree = cpuProfile.loadCodeTree('exclusive');
+ var node = tree.root;
+ var expected =
+ ['Root', 'test', 'test', '_FunctionImpl.call', 'runIsolateTests'];
+ for (var i = 0; i < expected.length; i++) {
+ expect(node.profileCode.code.name, equals(expected[i]));
+ // Depth first traversal.
+ if (node.children.length == 0) {
+ node = null;
+ } else {
+ node = node.children[0];
+ }
+ expect(node, isNotNull);
+ }
+ },
+ resumeIsolate,
+];
+
+main(args) async => runIsolateTests(args, tests, testeeConcurrent:test);
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698