diff options
Diffstat (limited to 'scripts/lib/build_perf/html/measurement_chart.html')
-rw-r--r-- | scripts/lib/build_perf/html/measurement_chart.html | 128 |
1 files changed, 98 insertions, 30 deletions
diff --git a/scripts/lib/build_perf/html/measurement_chart.html b/scripts/lib/build_perf/html/measurement_chart.html index ad4a93ed02..86435273cf 100644 --- a/scripts/lib/build_perf/html/measurement_chart.html +++ b/scripts/lib/build_perf/html/measurement_chart.html | |||
@@ -2,7 +2,7 @@ | |||
2 | // Get raw data | 2 | // Get raw data |
3 | const rawData = [ | 3 | const rawData = [ |
4 | {% for sample in measurement.samples %} | 4 | {% for sample in measurement.samples %} |
5 | [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}, {{ sample.start_time }}], | 5 | [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}, {{ sample.start_time }}, '{{sample.commit}}'], |
6 | {% endfor %} | 6 | {% endfor %} |
7 | ]; | 7 | ]; |
8 | 8 | ||
@@ -26,27 +26,37 @@ | |||
26 | ] | 26 | ] |
27 | }); | 27 | }); |
28 | 28 | ||
29 | const commitCountList = rawData.map(([commit, value, time]) => { | ||
30 | return commit | ||
31 | }); | ||
32 | |||
33 | const commitCountData = rawData.map(([commit, value, time]) => { | ||
34 | return updateValue(value) | ||
35 | }); | ||
36 | |||
29 | // Set chart options | 37 | // Set chart options |
30 | const option = { | 38 | const option_start_time = { |
31 | tooltip: { | 39 | tooltip: { |
32 | trigger: 'axis', | 40 | trigger: 'axis', |
33 | valueFormatter: (value) => { | 41 | enterable: true, |
34 | const commitNumber = rawData.filter(([commit, dataValue, time]) => updateValue(dataValue) === value) | 42 | position: function (point, params, dom, rect, size) { |
43 | return [point[0], '0%']; | ||
44 | }, | ||
45 | formatter: function (param) { | ||
46 | const value = param[0].value[1] | ||
47 | const sample = rawData.filter(([commit, dataValue]) => updateValue(dataValue) === value) | ||
48 | const formattedDate = new Date(sample[0][2] * 1000).toString().replace(/GMT[+-]\d{4}/, '').replace(/\(.*\)/, '(CEST)'); | ||
49 | |||
50 | // Add commit hash to the tooltip as a link | ||
51 | const commitLink = `https://git.yoctoproject.org/poky/commit/?id=${sample[0][3]}` | ||
35 | if ('{{ measurement.value_type.quantity }}' == 'time') { | 52 | if ('{{ measurement.value_type.quantity }}' == 'time') { |
36 | const hours = Math.floor(value/60) | 53 | const hours = Math.floor(value/60) |
37 | const minutes = Math.floor(value % 60) | 54 | const minutes = Math.floor(value % 60) |
38 | const seconds = Math.floor((value * 60) % 60) | 55 | const seconds = Math.floor((value * 60) % 60) |
39 | return [ | 56 | return `<strong>Duration:</strong> ${hours}:${minutes}:${seconds}, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` |
40 | hours + ':' + minutes + ':' + seconds + ', ' + | ||
41 | 'commit number: ' + commitNumber[0][0] | ||
42 | ] | ||
43 | } | 57 | } |
44 | return [ | 58 | return `<strong>Size:</strong> ${value.toFixed(2)} MB, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` |
45 | value.toFixed(2) + ' MB' + ', ' + | 59 | ;} |
46 | 'commit number: ' + commitNumber[0][0] | ||
47 | ] | ||
48 | }, | ||
49 | |||
50 | }, | 60 | }, |
51 | xAxis: { | 61 | xAxis: { |
52 | type: 'time', | 62 | type: 'time', |
@@ -72,29 +82,87 @@ | |||
72 | { | 82 | { |
73 | name: '{{ measurement.value_type.quantity }}', | 83 | name: '{{ measurement.value_type.quantity }}', |
74 | type: 'line', | 84 | type: 'line', |
75 | step: 'start', | ||
76 | symbol: 'none', | 85 | symbol: 'none', |
77 | data: data | 86 | data: data |
78 | } | 87 | } |
79 | ] | 88 | ] |
80 | }; | 89 | }; |
81 | 90 | ||
91 | const option_commit_count = { | ||
92 | tooltip: { | ||
93 | trigger: 'axis', | ||
94 | enterable: true, | ||
95 | position: function (point, params, dom, rect, size) { | ||
96 | return [point[0], '0%']; | ||
97 | }, | ||
98 | formatter: function (param) { | ||
99 | const value = param[0].value | ||
100 | const sample = rawData.filter(([commit, dataValue]) => updateValue(dataValue) === value) | ||
101 | const formattedDate = new Date(sample[0][2] * 1000).toString().replace(/GMT[+-]\d{4}/, '').replace(/\(.*\)/, '(CEST)'); | ||
102 | // Add commit hash to the tooltip as a link | ||
103 | const commitLink = `https://git.yoctoproject.org/poky/commit/?id=${sample[0][3]}` | ||
104 | if ('{{ measurement.value_type.quantity }}' == 'time') { | ||
105 | const hours = Math.floor(value/60) | ||
106 | const minutes = Math.floor(value % 60) | ||
107 | const seconds = Math.floor((value * 60) % 60) | ||
108 | return `<strong>Duration:</strong> ${hours}:${minutes}:${seconds}, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` | ||
109 | } | ||
110 | return `<strong>Size:</strong> ${value.toFixed(2)} MB, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` | ||
111 | ;} | ||
112 | }, | ||
113 | xAxis: { | ||
114 | name: 'Commit count', | ||
115 | type: 'category', | ||
116 | data: commitCountList | ||
117 | }, | ||
118 | yAxis: { | ||
119 | name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration in minutes' : 'Disk size in MB', | ||
120 | type: 'value', | ||
121 | min: function(value) { | ||
122 | return Math.round(value.min - 0.5); | ||
123 | }, | ||
124 | max: function(value) { | ||
125 | return Math.round(value.max + 0.5); | ||
126 | } | ||
127 | }, | ||
128 | dataZoom: [ | ||
129 | { | ||
130 | type: 'slider', | ||
131 | xAxisIndex: 0, | ||
132 | filterMode: 'none' | ||
133 | }, | ||
134 | ], | ||
135 | series: [ | ||
136 | { | ||
137 | name: '{{ measurement.value_type.quantity }}', | ||
138 | type: 'line', | ||
139 | symbol: 'none', | ||
140 | data: commitCountData | ||
141 | } | ||
142 | ] | ||
143 | }; | ||
144 | |||
82 | // Draw chart | 145 | // Draw chart |
83 | const chart_div = document.getElementById('{{ chart_elem_id }}'); | 146 | const draw_chart = (chart_id, option) => { |
84 | // Set dark mode | 147 | let chart_name |
85 | let measurement_chart | 148 | const chart_div = document.getElementById(chart_id); |
86 | if (window.matchMedia('(prefers-color-scheme: dark)').matches) { | 149 | // Set dark mode |
87 | measurement_chart= echarts.init(chart_div, 'dark', { | 150 | if (window.matchMedia('(prefers-color-scheme: dark)').matches) { |
88 | height: 320 | 151 | chart_name= echarts.init(chart_div, 'dark', { |
89 | }); | 152 | height: 320 |
90 | } else { | 153 | }); |
91 | measurement_chart= echarts.init(chart_div, null, { | 154 | } else { |
92 | height: 320 | 155 | chart_name= echarts.init(chart_div, null, { |
156 | height: 320 | ||
157 | }); | ||
158 | } | ||
159 | // Change chart size with browser resize | ||
160 | window.addEventListener('resize', function() { | ||
161 | chart_name.resize(); | ||
93 | }); | 162 | }); |
163 | return chart_name.setOption(option); | ||
94 | } | 164 | } |
95 | // Change chart size with browser resize | 165 | |
96 | window.addEventListener('resize', function() { | 166 | draw_chart('{{ chart_elem_start_time_id }}', option_start_time) |
97 | measurement_chart.resize(); | 167 | draw_chart('{{ chart_elem_commit_count_id }}', option_commit_count) |
98 | }); | ||
99 | measurement_chart.setOption(option); | ||
100 | </script> | 168 | </script> |