Chromium Code Reviews| Index: runtime/observatory/tests/service/get_cpu_profile_test.dart |
| diff --git a/runtime/observatory/tests/service/get_cpu_profile_test.dart b/runtime/observatory/tests/service/get_cpu_profile_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..822e2d85bc9ac1ab015a052d703f59d1c6480c8c |
| --- /dev/null |
| +++ b/runtime/observatory/tests/service/get_cpu_profile_test.dart |
| @@ -0,0 +1,92 @@ |
| +// 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() { |
| + // Initial. |
| + debugger(); |
| + // Toggle on. |
| + debugger(); |
| + // Step. |
| + debugger(); |
| + // Allocation. |
| + new Foo(); |
| + debugger(); |
| +} |
| + |
| +var tests = [ |
| + hasStoppedAtBreakpoint, |
|
turnidge
2015/07/13 23:37:48
Can you add blank lines between tests? it helps m
Cutch
2015/07/14 15:53:47
Done.
|
| + // Initial. |
| + (Isolate isolate) async { |
| + // Verify initial state of 'Foo'. |
| + var fooClass = await getRootClass(isolate, 'Foo'); |
| + expect(fooClass, isNotNull); |
| + expect(fooClass.name, equals('Foo')); |
| + print(fooClass.id); |
| + expect(fooClass.traceAllocations, isFalse); |
| + }, |
| + resumeIsolate, |
| + hasStoppedAtBreakpoint, |
|
turnidge
2015/07/13 23:37:48
It looks to me like this resume/breakpoint is unne
Cutch
2015/07/14 15:53:47
There is an issue between debugger stepping and al
|
| + // Toggle on. |
| + (Isolate isolate) async { |
| + // Enable allocation tracing for 'Foo'. |
| + var fooClass = await getRootClass(isolate, 'Foo'); |
| + await fooClass.reload(); |
| + expect(fooClass.traceAllocations, isFalse); |
| + await fooClass.setTraceAllocations(true); |
| + await fooClass.reload(); |
| + expect(fooClass.traceAllocations, isTrue); |
| + }, |
| + resumeIsolate, |
| + hasStoppedAtBreakpoint, |
| + // Step. |
|
turnidge
2015/07/13 23:37:48
Calling this Step is inaccurate, since we aren't s
Cutch
2015/07/14 15:53:47
Done.
|
| + resumeIsolate, |
| + hasStoppedAtBreakpoint, |
| + // Allocation profile. |
| + (Isolate isolate) async { |
| + var fooClass = await getRootClass(isolate, 'Foo'); |
| + await fooClass.reload(); |
| + expect(fooClass.traceAllocations, isTrue); |
| + var profileResponse = await fooClass.getAllocationProfile(); |
| + expect(profileResponse, isNotNull); |
| + expect(profileResponse['type'], equals('_CpuProfile')); |
| + await fooClass.setTraceAllocations(false); |
| + await fooClass.reload(); |
| + expect(fooClass.traceAllocations, isFalse); |
| + CpuProfile cpuProfile = new CpuProfile(); |
|
turnidge
2015/07/13 23:37:48
I think we should change the name CpuProfile to so
Cutch
2015/07/14 15:53:47
I agree. The CPU profile is slowly becoming a gene
|
| + 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); |