summaryrefslogtreecommitdiffstats
path: root/scripts/lib/build_perf
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/build_perf')
-rw-r--r--scripts/lib/build_perf/html/measurement_chart.html214
-rw-r--r--scripts/lib/build_perf/html/report.html195
-rw-r--r--scripts/lib/build_perf/report.py5
3 files changed, 327 insertions, 87 deletions
diff --git a/scripts/lib/build_perf/html/measurement_chart.html b/scripts/lib/build_perf/html/measurement_chart.html
index 65f1a227ad..86435273cf 100644
--- a/scripts/lib/build_perf/html/measurement_chart.html
+++ b/scripts/lib/build_perf/html/measurement_chart.html
@@ -1,50 +1,168 @@
1<script type="text/javascript"> 1<script type="module">
2 chartsDrawing += 1; 2 // Get raw data
3 google.charts.setOnLoadCallback(drawChart_{{ chart_elem_id }}); 3 const rawData = [
4 function drawChart_{{ chart_elem_id }}() { 4 {% for sample in measurement.samples %}
5 var data = new google.visualization.DataTable(); 5 [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}, {{ sample.start_time }}, '{{sample.commit}}'],
6 6 {% endfor %}
7 // Chart options 7 ];
8 var options = { 8
9 theme : 'material', 9 const convertToMinute = (time) => {
10 legend: 'none', 10 return time[0]*60 + time[1] + time[2]/60 + time[3]/3600;
11 hAxis: { format: '', title: 'Commit number', 11 }
12 minValue: {{ chart_opts.haxis.min }}, 12
13 maxValue: {{ chart_opts.haxis.max }} }, 13 // Update value format to either minutes or leave as size value
14 {% if measurement.type == 'time' %} 14 const updateValue = (value) => {
15 vAxis: { format: 'h:mm:ss' }, 15 // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds]
16 {% else %} 16 return Array.isArray(value) ? convertToMinute(value) : value
17 vAxis: { format: '' }, 17 }
18 {% endif %} 18
19 pointSize: 5, 19 // Convert raw data to the format: [time, value]
20 chartArea: { left: 80, right: 15 }, 20 const data = rawData.map(([commit, value, time]) => {
21 }; 21 return [
22 22 // The Date object takes values in milliseconds rather than seconds. So to use a Unix timestamp we have to multiply it by 1000.
23 // Define data columns 23 new Date(time * 1000).getTime(),
24 data.addColumn('number', 'Commit'); 24 // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds]
25 data.addColumn('{{ measurement.value_type.gv_data_type }}', 25 updateValue(value)
26 '{{ measurement.value_type.quantity }}'); 26 ]
27 // Add data rows 27 });
28 data.addRows([ 28
29 {% for sample in measurement.samples %} 29 const commitCountList = rawData.map(([commit, value, time]) => {
30 [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}], 30 return commit
31 {% endfor %} 31 });
32 ]); 32
33 33 const commitCountData = rawData.map(([commit, value, time]) => {
34 // Finally, draw the chart 34 return updateValue(value)
35 chart_div = document.getElementById('{{ chart_elem_id }}'); 35 });
36 var chart = new google.visualization.LineChart(chart_div); 36
37 google.visualization.events.addListener(chart, 'ready', function () { 37 // Set chart options
38 //chart_div = document.getElementById('{{ chart_elem_id }}'); 38 const option_start_time = {
39 //chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">'; 39 tooltip: {
40 png_div = document.getElementById('{{ chart_elem_id }}_png'); 40 trigger: 'axis',
41 png_div.outerHTML = '<a id="{{ chart_elem_id }}_png" href="' + chart.getImageURI() + '">PNG</a>'; 41 enterable: true,
42 console.log("CHART READY: {{ chart_elem_id }}"); 42 position: function (point, params, dom, rect, size) {
43 chartsDrawing -= 1; 43 return [point[0], '0%'];
44 if (chartsDrawing == 0) 44 },
45 console.log("ALL CHARTS READY"); 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]}`
52 if ('{{ measurement.value_type.quantity }}' == 'time') {
53 const hours = Math.floor(value/60)
54 const minutes = Math.floor(value % 60)
55 const seconds = Math.floor((value * 60) % 60)
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}`
57 }
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}`
59 ;}
60 },
61 xAxis: {
62 type: 'time',
63 },
64 yAxis: {
65 name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration in minutes' : 'Disk size in MB',
66 type: 'value',
67 min: function(value) {
68 return Math.round(value.min - 0.5);
69 },
70 max: function(value) {
71 return Math.round(value.max + 0.5);
72 }
73 },
74 dataZoom: [
75 {
76 type: 'slider',
77 xAxisIndex: 0,
78 filterMode: 'none'
79 },
80 ],
81 series: [
82 {
83 name: '{{ measurement.value_type.quantity }}',
84 type: 'line',
85 symbol: 'none',
86 data: data
87 }
88 ]
89 };
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
145 // Draw chart
146 const draw_chart = (chart_id, option) => {
147 let chart_name
148 const chart_div = document.getElementById(chart_id);
149 // Set dark mode
150 if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
151 chart_name= echarts.init(chart_div, 'dark', {
152 height: 320
153 });
154 } else {
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();
46 }); 162 });
47 chart.draw(data, options); 163 return chart_name.setOption(option);
48} 164 }
49</script>
50 165
166 draw_chart('{{ chart_elem_start_time_id }}', option_start_time)
167 draw_chart('{{ chart_elem_commit_count_id }}', option_commit_count)
168</script>
diff --git a/scripts/lib/build_perf/html/report.html b/scripts/lib/build_perf/html/report.html
index d1ba6f2578..28cd80e738 100644
--- a/scripts/lib/build_perf/html/report.html
+++ b/scripts/lib/build_perf/html/report.html
@@ -3,17 +3,14 @@
3<head> 3<head>
4{# Scripts, for visualization#} 4{# Scripts, for visualization#}
5<!--START-OF-SCRIPTS--> 5<!--START-OF-SCRIPTS-->
6<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 6<script src=" https://cdn.jsdelivr.net/npm/echarts@5.5.0/dist/echarts.min.js "></script>
7<script type="text/javascript">
8google.charts.load('current', {'packages':['corechart']});
9var chartsDrawing = 0;
10</script>
11 7
12{# Render measurement result charts #} 8{# Render measurement result charts #}
13{% for test in test_data %} 9{% for test in test_data %}
14 {% if test.status == 'SUCCESS' %} 10 {% if test.status == 'SUCCESS' %}
15 {% for measurement in test.measurements %} 11 {% for measurement in test.measurements %}
16 {% set chart_elem_id = test.name + '_' + measurement.name + '_chart' %} 12 {% set chart_elem_start_time_id = test.name + '_' + measurement.name + '_chart_start_time' %}
13 {% set chart_elem_commit_count_id = test.name + '_' + measurement.name + '_chart_commit_count' %}
17 {% include 'measurement_chart.html' %} 14 {% include 'measurement_chart.html' %}
18 {% endfor %} 15 {% endfor %}
19 {% endif %} 16 {% endif %}
@@ -23,28 +20,29 @@ var chartsDrawing = 0;
23 20
24{# Styles #} 21{# Styles #}
25<style> 22<style>
23:root {
24 --text: #000;
25 --bg: #fff;
26 --h2heading: #707070;
27 --link: #0000EE;
28 --trtopborder: #9ca3af;
29 --trborder: #e5e7eb;
30 --chartborder: #f0f0f0;
31 }
26.meta-table { 32.meta-table {
27 font-size: 14px; 33 font-size: 14px;
28 text-align: left; 34 text-align: left;
29 border-collapse: collapse; 35 border-collapse: collapse;
30} 36}
31.meta-table tr:nth-child(even){background-color: #f2f2f2}
32meta-table th, .meta-table td {
33 padding: 4px;
34}
35.summary { 37.summary {
36 margin: 0;
37 font-size: 14px; 38 font-size: 14px;
38 text-align: left; 39 text-align: left;
39 border-collapse: collapse; 40 border-collapse: collapse;
40} 41}
41summary th, .meta-table td {
42 padding: 4px;
43}
44.measurement { 42.measurement {
45 padding: 8px 0px 8px 8px; 43 padding: 8px 0px 8px 8px;
46 border: 2px solid #f0f0f0; 44 border: 2px solid var(--chartborder);
47 margin-bottom: 10px; 45 margin: 1.5rem 0;
48} 46}
49.details { 47.details {
50 margin: 0; 48 margin: 0;
@@ -64,18 +62,97 @@ summary th, .meta-table td {
64 background-color: #f0f0f0; 62 background-color: #f0f0f0;
65 margin-left: 10px; 63 margin-left: 10px;
66} 64}
67hr { 65.card-container {
68 color: #f0f0f0; 66 border-bottom-width: 1px;
67 padding: 1.25rem 3rem;
68 box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
69 border-radius: 0.25rem;
70}
71body {
72 font-family: 'Helvetica', sans-serif;
73 margin: 3rem 8rem;
74 background-color: var(--bg);
75 color: var(--text);
76}
77h1 {
78 text-align: center;
69} 79}
70h2 { 80h2 {
71 font-size: 20px; 81 font-size: 1.5rem;
72 margin-bottom: 0px; 82 margin-bottom: 0px;
73 color: #707070; 83 color: var(--h2heading);
84 padding-top: 1.5rem;
74} 85}
75h3 { 86h3 {
76 font-size: 16px; 87 font-size: 1.3rem;
77 margin: 0px; 88 margin: 0px;
78 color: #707070; 89 color: var(--h2heading);
90 padding: 1.5rem 0;
91}
92h4 {
93 font-size: 14px;
94 font-weight: lighter;
95 line-height: 1.2rem;
96 margin: auto;
97 padding-top: 1rem;
98}
99table {
100 margin-top: 1.5rem;
101 line-height: 2rem;
102}
103tr {
104 border-bottom: 1px solid var(--trborder);
105}
106tr:first-child {
107 border-bottom: 1px solid var(--trtopborder);
108}
109tr:last-child {
110 border-bottom: none;
111}
112a {
113 text-decoration: none;
114 font-weight: bold;
115 color: var(--link);
116}
117a:hover {
118 color: #8080ff;
119}
120button {
121 background-color: #F3F4F6;
122 border: none;
123 outline: none;
124 cursor: pointer;
125 padding: 10px 12px;
126 transition: 0.3s;
127 border-radius: 8px;
128 color: #3A4353;
129}
130button:hover {
131 background-color: #d6d9e0;
132}
133.tab button.active {
134 background-color: #d6d9e0;
135}
136@media (prefers-color-scheme: dark) {
137 :root {
138 --text: #e9e8fa;
139 --bg: #0F0C28;
140 --h2heading: #B8B7CB;
141 --link: #87cefa;
142 --trtopborder: #394150;
143 --trborder: #212936;
144 --chartborder: #b1b0bf;
145 }
146 button {
147 background-color: #28303E;
148 color: #fff;
149 }
150 button:hover {
151 background-color: #545a69;
152 }
153 .tab button.active {
154 background-color: #545a69;
155 }
79} 156}
80</style> 157</style>
81 158
@@ -83,13 +160,14 @@ h3 {
83</head> 160</head>
84 161
85{% macro poky_link(commit) -%} 162{% macro poky_link(commit) -%}
86 <a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?id={{ commit }}">{{ commit[0:11] }}</a> 163 <a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?id={{ commit }}">{{ commit[0:11] }}</a>
87{%- endmacro %} 164{%- endmacro %}
88 165
89<body><div style="width: 700px"> 166<body><div>
167 <h1 style="text-align: center;">Performance Test Report</h1>
90 {# Test metadata #} 168 {# Test metadata #}
91 <h2>General</h2> 169 <h2>General</h2>
92 <hr> 170 <h4>The table provides an overview of the comparison between two selected commits from the same branch.</h4>
93 <table class="meta-table" style="width: 100%"> 171 <table class="meta-table" style="width: 100%">
94 <tr> 172 <tr>
95 <th></th> 173 <th></th>
@@ -112,19 +190,21 @@ h3 {
112 190
113 {# Test result summary #} 191 {# Test result summary #}
114 <h2>Test result summary</h2> 192 <h2>Test result summary</h2>
115 <hr> 193 <h4>The test summary presents a thorough breakdown of each test conducted on the branch, including details such as build time and disk space consumption. Additionally, it gives insights into the average time taken for test execution, along with absolute and relative values for a better understanding.</h4>
116 <table class="summary" style="width: 100%"> 194 <table class="summary" style="width: 100%">
195 <tr>
196 <th>Test name</th>
197 <th>Measurement description</th>
198 <th>Mean value</th>
199 <th>Absolute difference</th>
200 <th>Relative difference</th>
201 </tr>
117 {% for test in test_data %} 202 {% for test in test_data %}
118 {% if loop.index is even %}
119 {% set row_style = 'style="background-color: #f2f2f2"' %}
120 {% else %}
121 {% set row_style = 'style="background-color: #ffffff"' %}
122 {% endif %}
123 {% if test.status == 'SUCCESS' %} 203 {% if test.status == 'SUCCESS' %}
124 {% for measurement in test.measurements %} 204 {% for measurement in test.measurements %}
125 <tr {{ row_style }}> 205 <tr {{ row_style }}>
126 {% if loop.index == 1 %} 206 {% if loop.index == 1 %}
127 <td>{{ test.name }}: {{ test.description }}</td> 207 <td><a href=#{{test.name}}>{{ test.name }}: {{ test.description }}</a></td>
128 {% else %} 208 {% else %}
129 {# add empty cell in place of the test name#} 209 {# add empty cell in place of the test name#}
130 <td></td> 210 <td></td>
@@ -153,10 +233,12 @@ h3 {
153 </table> 233 </table>
154 234
155 {# Detailed test results #} 235 {# Detailed test results #}
236 <h2>Test details</h2>
237 <h4>The following section provides details of each test, accompanied by charts representing build time and disk usage over time or by commit number.</h4>
156 {% for test in test_data %} 238 {% for test in test_data %}
157 <h2>{{ test.name }}: {{ test.description }}</h2> 239 <h3 style="color: #000;" id={{test.name}}>{{ test.name }}: {{ test.description }}</h3>
158 <hr>
159 {% if test.status == 'SUCCESS' %} 240 {% if test.status == 'SUCCESS' %}
241 <div class="card-container">
160 {% for measurement in test.measurements %} 242 {% for measurement in test.measurements %}
161 <div class="measurement"> 243 <div class="measurement">
162 <h3>{{ measurement.description }}</h3> 244 <h3>{{ measurement.description }}</h3>
@@ -178,7 +260,18 @@ h3 {
178 <tr> 260 <tr>
179 <td style="width: 75%"> 261 <td style="width: 75%">
180 {# Linechart #} 262 {# Linechart #}
181 <div id="{{ test.name }}_{{ measurement.name }}_chart"></div> 263 <div class="tab {{ test.name }}_{{ measurement.name }}_tablinks">
264 <button class="tablinks active" onclick="openChart(event, '{{ test.name }}_{{ measurement.name }}_start_time', '{{ test.name }}_{{ measurement.name }}')">Chart with start time</button>
265 <button class="tablinks" onclick="openChart(event, '{{ test.name }}_{{ measurement.name }}_commit_count', '{{ test.name }}_{{ measurement.name }}')">Chart with commit count</button>
266 </div>
267 <div class="{{ test.name }}_{{ measurement.name }}_tabcontent">
268 <div id="{{ test.name }}_{{ measurement.name }}_start_time" class="tabcontent" style="display: block;">
269 <div id="{{ test.name }}_{{ measurement.name }}_chart_start_time"></div>
270 </div>
271 <div id="{{ test.name }}_{{ measurement.name }}_commit_count" class="tabcontent" style="display: none;">
272 <div id="{{ test.name }}_{{ measurement.name }}_chart_commit_count"></div>
273 </div>
274 </div>
182 </td> 275 </td>
183 <td> 276 <td>
184 {# Measurement statistics #} 277 {# Measurement statistics #}
@@ -275,7 +368,8 @@ h3 {
275 {% endif %} 368 {% endif %}
276 {% endif %} 369 {% endif %}
277 </div> 370 </div>
278 {% endfor %} 371 {% endfor %}
372 </div>
279 {# Unsuccessful test #} 373 {# Unsuccessful test #}
280 {% else %} 374 {% else %}
281 <span style="font-size: 150%; font-weight: bold; color: red;">{{ test.status }} 375 <span style="font-size: 150%; font-weight: bold; color: red;">{{ test.status }}
@@ -284,6 +378,31 @@ h3 {
284 <div class="preformatted">{{ test.message }}</div> 378 <div class="preformatted">{{ test.message }}</div>
285 {% endif %} 379 {% endif %}
286 {% endfor %} 380 {% endfor %}
287</div></body> 381</div>
288</html>
289 382
383<script>
384function openChart(event, chartType, chartName) {
385 let i, tabcontents, tablinks
386 tabcontents = document.querySelectorAll(`.${chartName}_tabcontent > .tabcontent`);
387 tabcontents.forEach((tabcontent) => {
388 tabcontent.style.display = "none";
389 });
390
391 tablinks = document.querySelectorAll(`.${chartName}_tablinks > .tablinks`);
392 tablinks.forEach((tabLink) => {
393 tabLink.classList.remove('active');
394 });
395
396 const targetTab = document.getElementById(chartType)
397 targetTab.style.display = "block";
398
399 // Call resize on the ECharts instance to redraw the chart
400 const chartContainer = targetTab.querySelector('div')
401 echarts.init(chartContainer).resize();
402
403 event.currentTarget.classList.add('active');
404}
405</script>
406
407</body>
408</html>
diff --git a/scripts/lib/build_perf/report.py b/scripts/lib/build_perf/report.py
index ab77424cc7..f4e6a92e09 100644
--- a/scripts/lib/build_perf/report.py
+++ b/scripts/lib/build_perf/report.py
@@ -294,7 +294,7 @@ class SizeVal(MeasurementVal):
294 return "null" 294 return "null"
295 return self / 1024 295 return self / 1024
296 296
297def measurement_stats(meas, prefix=''): 297def measurement_stats(meas, prefix='', time=0):
298 """Get statistics of a measurement""" 298 """Get statistics of a measurement"""
299 if not meas: 299 if not meas:
300 return {prefix + 'sample_cnt': 0, 300 return {prefix + 'sample_cnt': 0,
@@ -319,6 +319,8 @@ def measurement_stats(meas, prefix=''):
319 stats['quantity'] = val_cls.quantity 319 stats['quantity'] = val_cls.quantity
320 stats[prefix + 'sample_cnt'] = len(values) 320 stats[prefix + 'sample_cnt'] = len(values)
321 321
322 # Add start time for both type sysres and disk usage
323 start_time = time
322 mean_val = val_cls(mean(values)) 324 mean_val = val_cls(mean(values))
323 min_val = val_cls(min(values)) 325 min_val = val_cls(min(values))
324 max_val = val_cls(max(values)) 326 max_val = val_cls(max(values))
@@ -334,6 +336,7 @@ def measurement_stats(meas, prefix=''):
334 stats[prefix + 'max'] = max_val 336 stats[prefix + 'max'] = max_val
335 stats[prefix + 'minus'] = val_cls(mean_val - min_val) 337 stats[prefix + 'minus'] = val_cls(mean_val - min_val)
336 stats[prefix + 'plus'] = val_cls(max_val - mean_val) 338 stats[prefix + 'plus'] = val_cls(max_val - mean_val)
339 stats[prefix + 'start_time'] = start_time
337 340
338 return stats 341 return stats
339 342