Skip to content

Commit e810f35

Browse files
committed
MAGETWO-33860: Improve PAT build experience
1 parent 765f195 commit e810f35

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

dev/tests/performance/compare_reports.php

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
. ' -m - mainline report file' . PHP_EOL
1414
. ' -b - branch report file' . PHP_EOL
1515
. ' -o - output xml file' . PHP_EOL
16-
. ' -p - percent of measurements, that will be skipped (default = 15)' . PHP_EOL;
16+
. ' -p - percent of measurements, that will be skipped (default = 15)' . PHP_EOL
17+
. ' -t - plain text report file (optional)' . PHP_EOL;
1718

18-
$args = getopt('m:b:o:p::');
19+
$args = getopt('m:b:o:p:t:');
1920
if (empty($args)) {
2021
echo $usageMessage;
2122
exit(0);
@@ -24,13 +25,17 @@
2425
$mainlineFile = $args['m'];
2526
$branchFile = $args['b'];
2627
$outputFile = $args['o'];
28+
$plainReportFile = isset($args['t']) ? $args['t'] : false;
2729
$skipMeasurementsPercent = isset($args['p']) && $args['p'] != '' ? min(100, max(0, $args['p'])) : 15;
2830

2931
try {
3032
$mainlineResults = readResponseTimeReport($mainlineFile);
3133
$branchResults = readResponseTimeReport($branchFile);
3234

3335
$result = new SimpleXMLElement('<testResults version="1.2" />');
36+
$plainResult = [
37+
['STEP', 'DIFFERENCE', '', 'RESULT']
38+
];
3439
foreach (array_keys($mainlineResults) as $sampleName) {
3540
$success = isset($mainlineResults[$sampleName]['success'])
3641
&& $mainlineResults[$sampleName]['success']
@@ -46,13 +51,39 @@
4651
$sample->addAttribute('s', $success ? 'true' : 'false');
4752
$sample->addAttribute('t', round($deviation * 1000));
4853
$sample->addAttribute('lb', $sampleName . ' degradation');
54+
55+
if (strpos($sampleName, 'Admin - ') === false) {
56+
$plainResult[] = [
57+
$sampleName,
58+
$success ?
59+
sprintf(
60+
'%+.1f%%',
61+
$deviation
62+
) :
63+
'',
64+
$success ?
65+
sprintf(
66+
'(%+.0fms)',
67+
-getImprovementInMilliseconds(
68+
$mainlineResults[$sampleName]['times'],
69+
$branchResults[$sampleName]['times']
70+
)
71+
) :
72+
'',
73+
$success ?
74+
($deviation < -1.5 ? 'improvement' : ($deviation > 1.5 ? 'DEGRADATION' : 'ok')) :
75+
'FAILED'
76+
];
77+
}
4978
}
5079

5180
$dom = new DOMDocument("1.0");
5281
$dom->preserveWhiteSpace = false;
5382
$dom->formatOutput = true;
5483
$dom->loadXML($result->asXML());
5584
file_put_contents($outputFile, $dom->saveXML());
85+
86+
printPlainReport($plainResult, $plainReportFile);
5687
} catch (\Exception $e) {
5788
fwrite(STDERR, $e->getMessage() . "\n");
5889
exit(1);
@@ -89,3 +120,24 @@ function getDeviation(array $mainlineResults, array $branchResults)
89120
{
90121
return 100 * (getMeanValue($branchResults) / getMeanValue($mainlineResults) - 1);
91122
}
123+
124+
function getImprovementInMilliseconds(array $mainlineResults, array $branchResults)
125+
{
126+
return getMeanValue($mainlineResults) - getMeanValue($branchResults);
127+
}
128+
129+
function printPlainReport(array $plainReport, $plainReportFile)
130+
{
131+
$result = '';
132+
foreach ($plainReport as $sample) {
133+
$result .= sprintf('%-32s %10s %-10s %s' . PHP_EOL, $sample[0], $sample[1], $sample[2], $sample[3]);
134+
}
135+
echo PHP_EOL . PHP_EOL . PHP_EOL;
136+
echo "====================================================================" . PHP_EOL . PHP_EOL;
137+
echo $result . PHP_EOL;
138+
echo "====================================================================" . PHP_EOL;
139+
echo PHP_EOL . PHP_EOL . PHP_EOL;
140+
if ($plainReportFile !== false) {
141+
file_put_contents($plainReportFile, $result);
142+
}
143+
}

0 commit comments

Comments
 (0)