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.html140
-rw-r--r--scripts/lib/build_perf/html/report.html124
-rw-r--r--scripts/lib/build_perf/report.py8
3 files changed, 191 insertions, 81 deletions
diff --git a/scripts/lib/build_perf/html/measurement_chart.html b/scripts/lib/build_perf/html/measurement_chart.html
index 65f1a227ad..05bd84e6ce 100644
--- a/scripts/lib/build_perf/html/measurement_chart.html
+++ b/scripts/lib/build_perf/html/measurement_chart.html
@@ -1,50 +1,100 @@
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 {% endfor %}
7 ];
6 8
7 // Chart options 9 const convertToMinute = (time) => {
8 var options = { 10 return time[0]*60 + time[1] + time[2]/60 + time[3]/3600;
9 theme : 'material', 11 }
10 legend: 'none',
11 hAxis: { format: '', title: 'Commit number',
12 minValue: {{ chart_opts.haxis.min }},
13 maxValue: {{ chart_opts.haxis.max }} },
14 {% if measurement.type == 'time' %}
15 vAxis: { format: 'h:mm:ss' },
16 {% else %}
17 vAxis: { format: '' },
18 {% endif %}
19 pointSize: 5,
20 chartArea: { left: 80, right: 15 },
21 };
22 12
23 // Define data columns 13 // Update value format to either minutes or leave as size value
24 data.addColumn('number', 'Commit'); 14 const updateValue = (value) => {
25 data.addColumn('{{ measurement.value_type.gv_data_type }}', 15 // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds]
26 '{{ measurement.value_type.quantity }}'); 16 return Array.isArray(value) ? convertToMinute(value) : value
27 // Add data rows 17 }
28 data.addRows([
29 {% for sample in measurement.samples %}
30 [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}],
31 {% endfor %}
32 ]);
33 18
34 // Finally, draw the chart 19 // Convert raw data to the format: [time, value]
35 chart_div = document.getElementById('{{ chart_elem_id }}'); 20 const data = rawData.map(([commit, value, time]) => {
36 var chart = new google.visualization.LineChart(chart_div); 21 return [
37 google.visualization.events.addListener(chart, 'ready', function () { 22 // The Date object takes values in milliseconds rather than seconds. So to use a Unix timestamp we have to multiply it by 1000.
38 //chart_div = document.getElementById('{{ chart_elem_id }}'); 23 new Date(time * 1000).getTime(),
39 //chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">'; 24 // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds]
40 png_div = document.getElementById('{{ chart_elem_id }}_png'); 25 updateValue(value)
41 png_div.outerHTML = '<a id="{{ chart_elem_id }}_png" href="' + chart.getImageURI() + '">PNG</a>'; 26 ]
42 console.log("CHART READY: {{ chart_elem_id }}"); 27 });
43 chartsDrawing -= 1; 28
44 if (chartsDrawing == 0) 29 // Set chart options
45 console.log("ALL CHARTS READY"); 30 const option = {
31 tooltip: {
32 trigger: 'axis',
33 enterable: true,
34 position: function (point, params, dom, rect, size) {
35 return [point[0]-150, '10%'];
36 },
37 formatter: function (param) {
38 const value = param[0].value[1]
39 const sample = rawData.filter(([commit, dataValue]) => updateValue(dataValue) === value)
40 // Add commit hash to the tooltip as a link
41 const commitLink = `https://git.yoctoproject.org/poky/commit/?id=${sample[0][3]}`
42 if ('{{ measurement.value_type.quantity }}' == 'time') {
43 const hours = Math.floor(value/60)
44 const minutes = Math.floor(value % 60)
45 const seconds = Math.floor((value * 60) % 60)
46 return `<strong>Duration:</strong> ${hours}:${minutes}:${seconds}, <br/> <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>`
47 }
48 return `<strong>Size:</strong> ${value.toFixed(2)} MB, <br/> <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>`
49 ;}
50 },
51 xAxis: {
52 type: 'time',
53 },
54 yAxis: {
55 name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration in minutes' : 'Disk size in MB',
56 type: 'value',
57 min: function(value) {
58 return Math.round(value.min - 0.5);
59 },
60 max: function(value) {
61 return Math.round(value.max + 0.5);
62 }
63 },
64 dataZoom: [
65 {
66 type: 'slider',
67 xAxisIndex: 0,
68 filterMode: 'none'
69 },
70 ],
71 series: [
72 {
73 name: '{{ measurement.value_type.quantity }}',
74 type: 'line',
75 step: 'start',
76 symbol: 'none',
77 data: data
78 }
79 ]
80 };
81
82 // Draw chart
83 const chart_div = document.getElementById('{{ chart_elem_id }}');
84 // Set dark mode
85 let measurement_chart
86 if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
87 measurement_chart= echarts.init(chart_div, 'dark', {
88 height: 320
46 }); 89 });
47 chart.draw(data, options); 90 } else {
48} 91 measurement_chart= echarts.init(chart_div, null, {
92 height: 320
93 });
94 }
95 // Change chart size with browser resize
96 window.addEventListener('resize', function() {
97 measurement_chart.resize();
98 });
99 measurement_chart.setOption(option);
49</script> 100</script>
50
diff --git a/scripts/lib/build_perf/html/report.html b/scripts/lib/build_perf/html/report.html
index d1ba6f2578..537ed3ee52 100644
--- a/scripts/lib/build_perf/html/report.html
+++ b/scripts/lib/build_perf/html/report.html
@@ -3,11 +3,7 @@
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 %}
@@ -23,28 +19,29 @@ var chartsDrawing = 0;
23 19
24{# Styles #} 20{# Styles #}
25<style> 21<style>
22:root {
23 --text: #000;
24 --bg: #fff;
25 --h2heading: #707070;
26 --link: #0000EE;
27 --trtopborder: #9ca3af;
28 --trborder: #e5e7eb;
29 --chartborder: #f0f0f0;
30 }
26.meta-table { 31.meta-table {
27 font-size: 14px; 32 font-size: 14px;
28 text-align: left; 33 text-align: left;
29 border-collapse: collapse; 34 border-collapse: collapse;
30} 35}
31.meta-table tr:nth-child(even){background-color: #f2f2f2}
32meta-table th, .meta-table td {
33 padding: 4px;
34}
35.summary { 36.summary {
36 margin: 0;
37 font-size: 14px; 37 font-size: 14px;
38 text-align: left; 38 text-align: left;
39 border-collapse: collapse; 39 border-collapse: collapse;
40} 40}
41summary th, .meta-table td {
42 padding: 4px;
43}
44.measurement { 41.measurement {
45 padding: 8px 0px 8px 8px; 42 padding: 8px 0px 8px 8px;
46 border: 2px solid #f0f0f0; 43 border: 2px solid var(--chartborder);
47 margin-bottom: 10px; 44 margin: 1.5rem 0;
48} 45}
49.details { 46.details {
50 margin: 0; 47 margin: 0;
@@ -64,18 +61,71 @@ summary th, .meta-table td {
64 background-color: #f0f0f0; 61 background-color: #f0f0f0;
65 margin-left: 10px; 62 margin-left: 10px;
66} 63}
67hr { 64.card-container {
68 color: #f0f0f0; 65 border-bottom-width: 1px;
66 padding: 1.25rem 3rem;
67 box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
68 border-radius: 0.25rem;
69}
70body {
71 font-family: 'Helvetica', sans-serif;
72 margin: 3rem 8rem;
73 background-color: var(--bg);
74 color: var(--text);
75}
76h1 {
77 text-align: center;
69} 78}
70h2 { 79h2 {
71 font-size: 20px; 80 font-size: 1.5rem;
72 margin-bottom: 0px; 81 margin-bottom: 0px;
73 color: #707070; 82 color: var(--h2heading);
83 padding-top: 1.5rem;
74} 84}
75h3 { 85h3 {
76 font-size: 16px; 86 font-size: 1.3rem;
77 margin: 0px; 87 margin: 0px;
78 color: #707070; 88 color: var(--h2heading);
89 padding: 1.5rem 0;
90}
91h4 {
92 font-size: 14px;
93 font-weight: lighter;
94 line-height: 1.2rem;
95 margin: auto;
96 padding-top: 1rem;
97}
98table {
99 margin-top: 1.5rem;
100 line-height: 2rem;
101}
102tr {
103 border-bottom: 1px solid var(--trborder);
104}
105tr:first-child {
106 border-bottom: 1px solid var(--trtopborder);
107}
108tr:last-child {
109 border-bottom: none;
110}
111a {
112 text-decoration: none;
113 font-weight: bold;
114 color: var(--link);
115}
116a:hover {
117 color: #8080ff;
118}
119@media (prefers-color-scheme: dark) {
120 :root {
121 --text: #e9e8fa;
122 --bg: #0F0C28;
123 --h2heading: #B8B7CB;
124 --link: #87cefa;
125 --trtopborder: #394150;
126 --trborder: #212936;
127 --chartborder: #b1b0bf;
128 }
79} 129}
80</style> 130</style>
81 131
@@ -83,13 +133,14 @@ h3 {
83</head> 133</head>
84 134
85{% macro poky_link(commit) -%} 135{% macro poky_link(commit) -%}
86 <a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?id={{ commit }}">{{ commit[0:11] }}</a> 136 <a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?id={{ commit }}">{{ commit[0:11] }}</a>
87{%- endmacro %} 137{%- endmacro %}
88 138
89<body><div style="width: 700px"> 139<body><div>
140 <h1 style="text-align: center;">Performance Test Report</h1>
90 {# Test metadata #} 141 {# Test metadata #}
91 <h2>General</h2> 142 <h2>General</h2>
92 <hr> 143 <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%"> 144 <table class="meta-table" style="width: 100%">
94 <tr> 145 <tr>
95 <th></th> 146 <th></th>
@@ -112,19 +163,21 @@ h3 {
112 163
113 {# Test result summary #} 164 {# Test result summary #}
114 <h2>Test result summary</h2> 165 <h2>Test result summary</h2>
115 <hr> 166 <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%"> 167 <table class="summary" style="width: 100%">
168 <tr>
169 <th>Test name</th>
170 <th>Measurement description</th>
171 <th>Mean value</th>
172 <th>Absolute difference</th>
173 <th>Relative difference</th>
174 </tr>
117 {% for test in test_data %} 175 {% 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' %} 176 {% if test.status == 'SUCCESS' %}
124 {% for measurement in test.measurements %} 177 {% for measurement in test.measurements %}
125 <tr {{ row_style }}> 178 <tr {{ row_style }}>
126 {% if loop.index == 1 %} 179 {% if loop.index == 1 %}
127 <td>{{ test.name }}: {{ test.description }}</td> 180 <td><a href=#{{test.name}}>{{ test.name }}: {{ test.description }}</a></td>
128 {% else %} 181 {% else %}
129 {# add empty cell in place of the test name#} 182 {# add empty cell in place of the test name#}
130 <td></td> 183 <td></td>
@@ -153,10 +206,12 @@ h3 {
153 </table> 206 </table>
154 207
155 {# Detailed test results #} 208 {# Detailed test results #}
209 <h2>Test details</h2>
210 <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 %} 211 {% for test in test_data %}
157 <h2>{{ test.name }}: {{ test.description }}</h2> 212 <h3 style="color: #000;" id={{test.name}}>{{ test.name }}: {{ test.description }}</h3>
158 <hr>
159 {% if test.status == 'SUCCESS' %} 213 {% if test.status == 'SUCCESS' %}
214 <div class="card-container">
160 {% for measurement in test.measurements %} 215 {% for measurement in test.measurements %}
161 <div class="measurement"> 216 <div class="measurement">
162 <h3>{{ measurement.description }}</h3> 217 <h3>{{ measurement.description }}</h3>
@@ -275,7 +330,8 @@ h3 {
275 {% endif %} 330 {% endif %}
276 {% endif %} 331 {% endif %}
277 </div> 332 </div>
278 {% endfor %} 333 {% endfor %}
334 </div>
279 {# Unsuccessful test #} 335 {# Unsuccessful test #}
280 {% else %} 336 {% else %}
281 <span style="font-size: 150%; font-weight: bold; color: red;">{{ test.status }} 337 <span style="font-size: 150%; font-weight: bold; color: red;">{{ test.status }}
diff --git a/scripts/lib/build_perf/report.py b/scripts/lib/build_perf/report.py
index 4e8e2a8a93..f4e6a92e09 100644
--- a/scripts/lib/build_perf/report.py
+++ b/scripts/lib/build_perf/report.py
@@ -4,7 +4,8 @@
4# SPDX-License-Identifier: GPL-2.0-only 4# SPDX-License-Identifier: GPL-2.0-only
5# 5#
6"""Handling of build perf test reports""" 6"""Handling of build perf test reports"""
7from collections import OrderedDict, Mapping, namedtuple 7from collections import OrderedDict, namedtuple
8from collections.abc import Mapping
8from datetime import datetime, timezone 9from datetime import datetime, timezone
9from numbers import Number 10from numbers import Number
10from statistics import mean, stdev, variance 11from statistics import mean, stdev, variance
@@ -293,7 +294,7 @@ class SizeVal(MeasurementVal):
293 return "null" 294 return "null"
294 return self / 1024 295 return self / 1024
295 296
296def measurement_stats(meas, prefix=''): 297def measurement_stats(meas, prefix='', time=0):
297 """Get statistics of a measurement""" 298 """Get statistics of a measurement"""
298 if not meas: 299 if not meas:
299 return {prefix + 'sample_cnt': 0, 300 return {prefix + 'sample_cnt': 0,
@@ -318,6 +319,8 @@ def measurement_stats(meas, prefix=''):
318 stats['quantity'] = val_cls.quantity 319 stats['quantity'] = val_cls.quantity
319 stats[prefix + 'sample_cnt'] = len(values) 320 stats[prefix + 'sample_cnt'] = len(values)
320 321
322 # Add start time for both type sysres and disk usage
323 start_time = time
321 mean_val = val_cls(mean(values)) 324 mean_val = val_cls(mean(values))
322 min_val = val_cls(min(values)) 325 min_val = val_cls(min(values))
323 max_val = val_cls(max(values)) 326 max_val = val_cls(max(values))
@@ -333,6 +336,7 @@ def measurement_stats(meas, prefix=''):
333 stats[prefix + 'max'] = max_val 336 stats[prefix + 'max'] = max_val
334 stats[prefix + 'minus'] = val_cls(mean_val - min_val) 337 stats[prefix + 'minus'] = val_cls(mean_val - min_val)
335 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
336 340
337 return stats 341 return stats
338 342