| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // VMOptions=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'service_test_common.dart'; | 9 import 'service_test_common.dart'; |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 }); | 33 }); |
| 34 } | 34 } |
| 35 | 35 |
| 36 getRetainedSize(ServiceObject obj) { | 36 getRetainedSize(ServiceObject obj) { |
| 37 return obj.isolate.getRetainedSize(obj).then((Instance obj) { | 37 return obj.isolate.getRetainedSize(obj).then((Instance obj) { |
| 38 return int.parse(obj.valueAsString); | 38 return int.parse(obj.valueAsString); |
| 39 }); | 39 }); |
| 40 } | 40 } |
| 41 | 41 |
| 42 var tests = [ | 42 var tests = [ |
| 43 (Isolate isolate) async { | 43 (Isolate isolate) async { |
| 44 Instance p1 = await rootLibraryFieldValue(isolate, "p1"); | 44 Instance p1 = await rootLibraryFieldValue(isolate, "p1"); |
| 45 Instance p2 = await rootLibraryFieldValue(isolate, "p2"); | 45 Instance p2 = await rootLibraryFieldValue(isolate, "p2"); |
| 46 | 46 |
| 47 // In general, shallow <= retained <= reachable. In this program, | 47 // In general, shallow <= retained <= reachable. In this program, |
| 48 // 0 < shallow < retained < reachable. | 48 // 0 < shallow < retained < reachable. |
| 49 | 49 |
| 50 int p1_shallow = p1.size; | 50 int p1_shallow = p1.size; |
| 51 int p1_retained = await getRetainedSize(p1); | 51 int p1_retained = await getRetainedSize(p1); |
| 52 int p1_reachable = await getReachableSize(p1); | 52 int p1_reachable = await getReachableSize(p1); |
| 53 | 53 |
| 54 expect(0, lessThan(p1_shallow)); | 54 expect(0, lessThan(p1_shallow)); |
| 55 expect(p1_shallow, lessThan(p1_retained)); | 55 expect(p1_shallow, lessThan(p1_retained)); |
| 56 expect(p1_retained, lessThan(p1_reachable)); | 56 expect(p1_retained, lessThan(p1_reachable)); |
| 57 | 57 |
| 58 int p2_shallow = p2.size; | 58 int p2_shallow = p2.size; |
| 59 int p2_retained = await getRetainedSize(p2); | 59 int p2_retained = await getRetainedSize(p2); |
| 60 int p2_reachable = await getReachableSize(p2); | 60 int p2_reachable = await getReachableSize(p2); |
| 61 | 61 |
| 62 expect(0, lessThan(p2_shallow)); | 62 expect(0, lessThan(p2_shallow)); |
| 63 expect(p2_shallow, lessThan(p2_retained)); | 63 expect(p2_shallow, lessThan(p2_retained)); |
| 64 expect(p2_retained, lessThan(p2_reachable)); | 64 expect(p2_retained, lessThan(p2_reachable)); |
| 65 | 65 |
| 66 expect(p1_shallow, equals(p2_shallow)); | 66 expect(p1_shallow, equals(p2_shallow)); |
| 67 expect(p1_retained, equals(p2_retained)); | 67 expect(p1_retained, equals(p2_retained)); |
| 68 expect(p1_reachable, equals(p2_reachable)); | 68 expect(p1_reachable, equals(p2_reachable)); |
| 69 }, | 69 }, |
| 70 ]; | 70 ]; |
| 71 | 71 |
| 72 main(args) => runIsolateTests(args, tests, testeeBefore: buildGraph); | 72 main(args) => runIsolateTests(args, tests, testeeBefore: buildGraph); |
| OLD | NEW |