OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 8 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
9 <link rel="import" href="/tracing/base/multi_dimensional_view.html"> | 9 <link rel="import" href="/tracing/base/multi_dimensional_view.html"> |
10 <link rel="import" href="/tracing/base/range.html"> | 10 <link rel="import" href="/tracing/base/range.html"> |
(...skipping 17 matching lines...) Expand all Loading... |
28 var unitlessNumber_smallerIsBetter = | 28 var unitlessNumber_smallerIsBetter = |
29 tr.v.Unit.byName.unitlessNumber_smallerIsBetter; | 29 tr.v.Unit.byName.unitlessNumber_smallerIsBetter; |
30 var DISPLAYED_SIZE_NUMERIC_NAME = | 30 var DISPLAYED_SIZE_NUMERIC_NAME = |
31 tr.model.MemoryAllocatorDump.DISPLAYED_SIZE_NUMERIC_NAME; | 31 tr.model.MemoryAllocatorDump.DISPLAYED_SIZE_NUMERIC_NAME; |
32 | 32 |
33 var LEVEL_OF_DETAIL_NAMES = new Map(); | 33 var LEVEL_OF_DETAIL_NAMES = new Map(); |
34 LEVEL_OF_DETAIL_NAMES.set(BACKGROUND, 'background'); | 34 LEVEL_OF_DETAIL_NAMES.set(BACKGROUND, 'background'); |
35 LEVEL_OF_DETAIL_NAMES.set(LIGHT, 'light'); | 35 LEVEL_OF_DETAIL_NAMES.set(LIGHT, 'light'); |
36 LEVEL_OF_DETAIL_NAMES.set(DETAILED, 'detailed'); | 36 LEVEL_OF_DETAIL_NAMES.set(DETAILED, 'detailed'); |
37 | 37 |
38 var MEMORY_NUMERIC_BUILDER_MAP = new WeakMap(); | 38 var BOUNDARIES_FOR_UNIT_MAP = new WeakMap(); |
39 // For unitless numerics (process counts), we use 20 linearly scaled bins | 39 // For unitless numerics (process counts), we use 20 linearly scaled bins |
40 // from 0 to 20. | 40 // from 0 to 20. |
41 MEMORY_NUMERIC_BUILDER_MAP.set(unitlessNumber_smallerIsBetter, | 41 BOUNDARIES_FOR_UNIT_MAP.set(unitlessNumber_smallerIsBetter, |
42 tr.v.NumericBuilder.createLinear( | 42 tr.v.HistogramBinBoundaries.createLinear(0, 20, 20)); |
43 tr.v.Unit.byName.unitlessNumber_smallerIsBetter, | |
44 tr.b.Range.fromExplicitRange(0, 20), 20)); | |
45 // For size numerics (subsystem and vm stats), we use 1 bin from 0 B to | 43 // For size numerics (subsystem and vm stats), we use 1 bin from 0 B to |
46 // 1 KiB and 4*24 exponentially scaled bins from 1 KiB to 16 GiB (=2^24 KiB). | 44 // 1 KiB and 4*24 exponentially scaled bins from 1 KiB to 16 GiB (=2^24 KiB). |
47 MEMORY_NUMERIC_BUILDER_MAP.set(sizeInBytes_smallerIsBetter, | 45 BOUNDARIES_FOR_UNIT_MAP.set(sizeInBytes_smallerIsBetter, |
48 new tr.v.NumericBuilder(sizeInBytes_smallerIsBetter, 0) | 46 new tr.v.HistogramBinBoundaries(0) |
49 .addBinBoundary(1024 /* 1 KiB */) | 47 .addBinBoundary(1024 /* 1 KiB */) |
50 .addExponentialBins(16 * 1024 * 1024 * 1024 /* 16 GiB */, 4 * 24)); | 48 .addExponentialBins(16 * 1024 * 1024 * 1024 /* 16 GiB */, 4 * 24)); |
51 | 49 |
52 function memoryMetric(values, model, opt_options) { | 50 function memoryMetric(values, model, opt_options) { |
53 var rangeOfInterest = opt_options ? opt_options.rangeOfInterest : undefined; | 51 var rangeOfInterest = opt_options ? opt_options.rangeOfInterest : undefined; |
54 var browserNameToGlobalDumps = | 52 var browserNameToGlobalDumps = |
55 splitGlobalDumpsByBrowserName(model, rangeOfInterest); | 53 splitGlobalDumpsByBrowserName(model, rangeOfInterest); |
56 addGeneralMemoryDumpValues(browserNameToGlobalDumps, values); | 54 addGeneralMemoryDumpValues(browserNameToGlobalDumps, values); |
57 addDetailedMemoryDumpValues(browserNameToGlobalDumps, values); | 55 addDetailedMemoryDumpValues(browserNameToGlobalDumps, values); |
58 addMemoryDumpCountValues(browserNameToGlobalDumps, values); | 56 addMemoryDumpCountValues(browserNameToGlobalDumps, values); |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 * |levelOfDetailCount|. | 762 * |levelOfDetailCount|. |
765 */ | 763 */ |
766 function reportMemoryDumpCountAsValue( | 764 function reportMemoryDumpCountAsValue( |
767 browserName, levelOfDetailName, levelOfDetailDumpCount, values) { | 765 browserName, levelOfDetailName, levelOfDetailDumpCount, values) { |
768 // Construct the name of the memory value. | 766 // Construct the name of the memory value. |
769 var nameParts = ['memory', browserName, 'all_processes', 'dump_count']; | 767 var nameParts = ['memory', browserName, 'all_processes', 'dump_count']; |
770 if (levelOfDetailName !== undefined) | 768 if (levelOfDetailName !== undefined) |
771 nameParts.push(levelOfDetailName); | 769 nameParts.push(levelOfDetailName); |
772 var name = nameParts.join(':'); | 770 var name = nameParts.join(':'); |
773 | 771 |
774 // Build the underlying numeric for the memory value. | 772 // Build the underlying histogram for the memory value. |
775 var numeric = MEMORY_NUMERIC_BUILDER_MAP.get( | 773 var histogram = new tr.v.Histogram(unitlessNumber_smallerIsBetter, |
776 unitlessNumber_smallerIsBetter).build(); | 774 BOUNDARIES_FOR_UNIT_MAP.get(unitlessNumber_smallerIsBetter)); |
777 numeric.add(levelOfDetailDumpCount); | 775 histogram.add(levelOfDetailDumpCount); |
778 | 776 |
779 // Build the options for the memory value. | 777 // Build the options for the memory value. |
780 var description = [ | 778 var description = [ |
781 'total number of', | 779 'total number of', |
782 levelOfDetailName || 'all', | 780 levelOfDetailName || 'all', |
783 'memory dumps added by', | 781 'memory dumps added by', |
784 convertBrowserNameToUserFriendlyName(browserName), | 782 convertBrowserNameToUserFriendlyName(browserName), |
785 'to the trace' | 783 'to the trace' |
786 ].join(' '); | 784 ].join(' '); |
787 var options = { description: description }; | 785 var options = { description: description }; |
788 | 786 |
789 // Report the memory value. | 787 // Report the memory value. |
790 values.addValue(new tr.v.NumericValue(name, numeric, options)); | 788 values.addValue(new tr.v.NumericValue(name, histogram, options)); |
791 } | 789 } |
792 | 790 |
793 /** | 791 /** |
794 * Add generic values extracted from process memory dumps and aggregated by | 792 * Add generic values extracted from process memory dumps and aggregated by |
795 * process name and component path into |values|. | 793 * process name and component path into |values|. |
796 * | 794 * |
797 * For each browser and set of global dumps in |browserNameToGlobalDumps|, | 795 * For each browser and set of global dumps in |browserNameToGlobalDumps|, |
798 * |customProcessDumpValueExtractor| is applied to every process memory dump | 796 * |customProcessDumpValueExtractor| is applied to every process memory dump |
799 * associated with the global memory dump. The second argument provided to the | 797 * associated with the global memory dump. The second argument provided to the |
800 * callback is a function for adding extracted values: | 798 * callback is a function for adding extracted values: |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 childNode, unit, descriptionPrefixBuilder, values); | 1117 childNode, unit, descriptionPrefixBuilder, values); |
1120 }); | 1118 }); |
1121 componentPath.pop(); | 1119 componentPath.pop(); |
1122 } | 1120 } |
1123 | 1121 |
1124 /** | 1122 /** |
1125 * Create a memory tr.v.Histogram with |unit| and add all total values in | 1123 * Create a memory tr.v.Histogram with |unit| and add all total values in |
1126 * |node| to it. | 1124 * |node| to it. |
1127 */ | 1125 */ |
1128 function buildMemoryNumericFromNode(node, unit) { | 1126 function buildMemoryNumericFromNode(node, unit) { |
1129 var numeric = MEMORY_NUMERIC_BUILDER_MAP.get(unit).build(); | 1127 var numeric = new tr.v.Histogram(unit, BOUNDARIES_FOR_UNIT_MAP.get(unit)); |
1130 node.values.forEach(v => numeric.add(v.total)); | 1128 node.values.forEach(v => numeric.add(v.total)); |
1131 return numeric; | 1129 return numeric; |
1132 } | 1130 } |
1133 | 1131 |
1134 tr.metrics.MetricRegistry.register(memoryMetric, { | 1132 tr.metrics.MetricRegistry.register(memoryMetric, { |
1135 supportsRangeOfInterest: true | 1133 supportsRangeOfInterest: true |
1136 }); | 1134 }); |
1137 | 1135 |
1138 return { | 1136 return { |
1139 memoryMetric: memoryMetric | 1137 memoryMetric: memoryMetric |
1140 }; | 1138 }; |
1141 }); | 1139 }); |
1142 </script> | 1140 </script> |
OLD | NEW |