OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Copyright 2017 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. |
| 6 --> |
| 7 |
| 8 <link rel="import" href="/dashboard/static/memory_related_names.html"> |
| 9 |
| 10 <script> |
| 11 'use strict'; |
| 12 tr.exportTo('d', function() { |
| 13 /** |
| 14 * @param {Array.<{color: string, testpath: string}>} sources |
| 15 * @return {Array.<{ |
| 16 * name: string like 'Process' or 'Component' or 'Bot', |
| 17 * sparklines: Array.<{ |
| 18 * name: string like 'renderer_processes' or 'v8:heap', |
| 19 * testpaths: Array.<{color: string, testpath: string}> |
| 20 * }> |
| 21 * }>} |
| 22 */ |
| 23 function buildRelatedTimeseries(sources) { |
| 24 const tabs = new Map(); |
| 25 for (const source of sources) { |
| 26 const parts = source.testpath.split('/'); |
| 27 const measurementName = parts[3]; |
| 28 const prefix = parts.slice(0, 3).join('/') + '/'; |
| 29 let suffix = parts.slice(4).join('/'); |
| 30 if (suffix) suffix = '/' + suffix; |
| 31 |
| 32 if (d.MEMORY_PROCESS_RELATED_NAMES.has(measurementName)) { |
| 33 const sparklines = tabs.get('Process') || []; |
| 34 for (const relatedName of d.MEMORY_PROCESS_RELATED_NAMES.get( |
| 35 measurementName)) { |
| 36 if (relatedName === measurementName) continue; |
| 37 const relatedParts = relatedName.split(':'); |
| 38 const relatedProcessName = relatedParts[2]; |
| 39 const relatedTestPath = { |
| 40 testpath: prefix + relatedName + suffix, |
| 41 color: source.color, |
| 42 }; |
| 43 let found = false; |
| 44 for (const sparkline of sparklines) { |
| 45 if (sparkline.name === relatedProcessName) { |
| 46 found = true; |
| 47 sparkline.testpaths.push(relatedTestPath); |
| 48 } |
| 49 } |
| 50 if (!found) { |
| 51 sparklines.push({ |
| 52 name: relatedProcessName, |
| 53 testpaths: [relatedTestPath], |
| 54 }); |
| 55 } |
| 56 } |
| 57 if (sparklines.length) { |
| 58 tabs.set('Process', sparklines); |
| 59 } |
| 60 } |
| 61 |
| 62 if (d.MEMORY_COMPONENT_RELATED_NAMES.has(measurementName)) { |
| 63 const sparklines = tabs.get('Component') || []; |
| 64 for (const relatedName of d.MEMORY_COMPONENT_RELATED_NAMES.get( |
| 65 measurementName)) { |
| 66 if (relatedName === measurementName) continue; |
| 67 const relatedParts = relatedName.split(':'); |
| 68 const componentName = relatedParts.slice( |
| 69 4, relatedParts.length - 1).join(':'); |
| 70 const relatedTestPath = { |
| 71 testpath: prefix + relatedName + suffix, |
| 72 color: source.color, |
| 73 }; |
| 74 let found = false; |
| 75 for (const sparkline of sparklines) { |
| 76 if (sparkline.name === componentName) { |
| 77 found = true; |
| 78 sparkline.testpaths.push(relatedTestPath); |
| 79 } |
| 80 } |
| 81 if (!found) { |
| 82 sparklines.push({ |
| 83 name: componentName, |
| 84 testpaths: [relatedTestPath], |
| 85 }); |
| 86 } |
| 87 } |
| 88 if (sparklines.length) { |
| 89 tabs.set('Component', sparklines); |
| 90 } |
| 91 } |
| 92 } |
| 93 |
| 94 const relatedTabs = []; |
| 95 for (const [name, sparklines] of tabs) { |
| 96 relatedTabs.push({name, sparklines}); |
| 97 } |
| 98 return relatedTabs; |
| 99 } |
| 100 |
| 101 return { |
| 102 buildRelatedTimeseries, |
| 103 }; |
| 104 }); |
| 105 </script> |
OLD | NEW |