| 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 | 4 |
| 5 part of cpu_profiler; | 5 part of cpu_profiler; |
| 6 | 6 |
| 7 abstract class CallTreeNode<NodeT extends M.CallTreeNode> | 7 abstract class CallTreeNode<NodeT extends M.CallTreeNode> |
| 8 implements M.CallTreeNode { | 8 implements M.CallTreeNode { |
| 9 final List<NodeT> children; | 9 final List<NodeT> children; |
| 10 final int count; | 10 final int count; |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 String formattedCpuTime = ''; | 470 String formattedCpuTime = ''; |
| 471 String formattedOnStackTime = ''; | 471 String formattedOnStackTime = ''; |
| 472 final Set<String> attributes = new Set<String>(); | 472 final Set<String> attributes = new Set<String>(); |
| 473 final Map<ProfileCode, int> callers = new Map<ProfileCode, int>(); | 473 final Map<ProfileCode, int> callers = new Map<ProfileCode, int>(); |
| 474 final Map<ProfileCode, int> callees = new Map<ProfileCode, int>(); | 474 final Map<ProfileCode, int> callees = new Map<ProfileCode, int>(); |
| 475 | 475 |
| 476 void _processTicks(List<String> profileTicks) { | 476 void _processTicks(List<String> profileTicks) { |
| 477 assert(profileTicks != null); | 477 assert(profileTicks != null); |
| 478 assert((profileTicks.length % 3) == 0); | 478 assert((profileTicks.length % 3) == 0); |
| 479 for (var i = 0; i < profileTicks.length; i += 3) { | 479 for (var i = 0; i < profileTicks.length; i += 3) { |
| 480 // TODO(observatory): Address is not necessarily representable as a JS |
| 481 // integer. |
| 480 var address = int.parse(profileTicks[i], radix: 16); | 482 var address = int.parse(profileTicks[i], radix: 16); |
| 481 var exclusive = int.parse(profileTicks[i + 1]); | 483 var exclusive = profileTicks[i + 1]; |
| 482 var inclusive = int.parse(profileTicks[i + 2]); | 484 var inclusive = profileTicks[i + 2]; |
| 483 var tick = new CodeTick(exclusive, inclusive); | 485 var tick = new CodeTick(exclusive, inclusive); |
| 484 addressTicks[address] = tick; | 486 addressTicks[address] = tick; |
| 485 | 487 |
| 486 var interval = code.findInterval(address); | 488 var interval = code.findInterval(address); |
| 487 if (interval != null) { | 489 if (interval != null) { |
| 488 var intervalTick = intervalTicks[interval.start]; | 490 var intervalTick = intervalTicks[interval.start]; |
| 489 if (intervalTick == null) { | 491 if (intervalTick == null) { |
| 490 // Insert into map. | 492 // Insert into map. |
| 491 intervalTick = new InlineIntervalTick(interval.start); | 493 intervalTick = new InlineIntervalTick(interval.start); |
| 492 intervalTicks[interval.start] = intervalTick; | 494 intervalTicks[interval.start] = intervalTick; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 517 if (code.isOptimized) { | 519 if (code.isOptimized) { |
| 518 attributes.add('optimized'); | 520 attributes.add('optimized'); |
| 519 } else { | 521 } else { |
| 520 attributes.add('unoptimized'); | 522 attributes.add('unoptimized'); |
| 521 } | 523 } |
| 522 } else if (code.kind == M.CodeKind.tag) { | 524 } else if (code.kind == M.CodeKind.tag) { |
| 523 attributes.add('tag'); | 525 attributes.add('tag'); |
| 524 } else if (code.kind == M.CodeKind.native) { | 526 } else if (code.kind == M.CodeKind.native) { |
| 525 attributes.add('native'); | 527 attributes.add('native'); |
| 526 } | 528 } |
| 527 inclusiveTicks = int.parse(data['inclusiveTicks']); | 529 inclusiveTicks = data['inclusiveTicks']; |
| 528 exclusiveTicks = int.parse(data['exclusiveTicks']); | 530 exclusiveTicks = data['exclusiveTicks']; |
| 529 | 531 |
| 530 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; | 532 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; |
| 531 | 533 |
| 532 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; | 534 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; |
| 533 | 535 |
| 534 var ticks = data['ticks']; | 536 var ticks = data['ticks']; |
| 535 if (ticks != null) { | 537 if (ticks != null) { |
| 536 _processTicks(ticks); | 538 _processTicks(ticks); |
| 537 } | 539 } |
| 538 | 540 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 685 |
| 684 ProfileFunction.fromMap(this.profile, this.function, Map data) { | 686 ProfileFunction.fromMap(this.profile, this.function, Map data) { |
| 685 function.profile = this; | 687 function.profile = this; |
| 686 for (var codeIndex in data['codes']) { | 688 for (var codeIndex in data['codes']) { |
| 687 var profileCode = profile.codes[codeIndex]; | 689 var profileCode = profile.codes[codeIndex]; |
| 688 profileCodes.add(profileCode); | 690 profileCodes.add(profileCode); |
| 689 } | 691 } |
| 690 profileCodes.sort(_sortCodes); | 692 profileCodes.sort(_sortCodes); |
| 691 | 693 |
| 692 _addKindBasedAttributes(attributes); | 694 _addKindBasedAttributes(attributes); |
| 693 exclusiveTicks = int.parse(data['exclusiveTicks']); | 695 exclusiveTicks = data['exclusiveTicks']; |
| 694 inclusiveTicks = int.parse(data['inclusiveTicks']); | 696 inclusiveTicks = data['inclusiveTicks']; |
| 695 | 697 |
| 696 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; | 698 normalizedExclusiveTicks = exclusiveTicks / profile.sampleCount; |
| 697 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; | 699 normalizedInclusiveTicks = inclusiveTicks / profile.sampleCount; |
| 698 | 700 |
| 699 if (data.containsKey('exclusiveNativeAllocations') && | 701 if (data.containsKey('exclusiveNativeAllocations') && |
| 700 data.containsKey('inclusiveNativeAllocations')) { | 702 data.containsKey('inclusiveNativeAllocations')) { |
| 701 exclusiveNativeAllocations = | 703 exclusiveNativeAllocations = |
| 702 int.parse(data['exclusiveNativeAllocations']); | 704 int.parse(data['exclusiveNativeAllocations']); |
| 703 inclusiveNativeAllocations = | 705 inclusiveNativeAllocations = |
| 704 int.parse(data['inclusiveNativeAllocations']); | 706 int.parse(data['inclusiveNativeAllocations']); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 } | 1075 } |
| 1074 | 1076 |
| 1075 int approximateMillisecondsForCount(count) { | 1077 int approximateMillisecondsForCount(count) { |
| 1076 return (count * samplePeriod) ~/ Duration.MICROSECONDS_PER_MILLISECOND; | 1078 return (count * samplePeriod) ~/ Duration.MICROSECONDS_PER_MILLISECOND; |
| 1077 } | 1079 } |
| 1078 | 1080 |
| 1079 double approximateSecondsForCount(count) { | 1081 double approximateSecondsForCount(count) { |
| 1080 return (count * samplePeriod) / Duration.MICROSECONDS_PER_SECOND; | 1082 return (count * samplePeriod) / Duration.MICROSECONDS_PER_SECOND; |
| 1081 } | 1083 } |
| 1082 } | 1084 } |
| OLD | NEW |