13
13
. ' -m - mainline report file ' . PHP_EOL
14
14
. ' -b - branch report file ' . PHP_EOL
15
15
. ' -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 ;
17
18
18
- $ args = getopt ('m:b:o:p:: ' );
19
+ $ args = getopt ('m:b:o:p:t : ' );
19
20
if (empty ($ args )) {
20
21
echo $ usageMessage ;
21
22
exit (0 );
24
25
$ mainlineFile = $ args ['m ' ];
25
26
$ branchFile = $ args ['b ' ];
26
27
$ outputFile = $ args ['o ' ];
28
+ $ plainReportFile = isset ($ args ['t ' ]) ? $ args ['t ' ] : false ;
27
29
$ skipMeasurementsPercent = isset ($ args ['p ' ]) && $ args ['p ' ] != '' ? min (100 , max (0 , $ args ['p ' ])) : 15 ;
28
30
29
31
try {
30
32
$ mainlineResults = readResponseTimeReport ($ mainlineFile );
31
33
$ branchResults = readResponseTimeReport ($ branchFile );
32
34
33
35
$ result = new SimpleXMLElement ('<testResults version="1.2" /> ' );
36
+ $ plainResult = [
37
+ ['STEP ' , 'DIFFERENCE ' , '' , 'RESULT ' ]
38
+ ];
34
39
foreach (array_keys ($ mainlineResults ) as $ sampleName ) {
35
40
$ success = isset ($ mainlineResults [$ sampleName ]['success ' ])
36
41
&& $ mainlineResults [$ sampleName ]['success ' ]
46
51
$ sample ->addAttribute ('s ' , $ success ? 'true ' : 'false ' );
47
52
$ sample ->addAttribute ('t ' , round ($ deviation * 1000 ));
48
53
$ 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
+ }
49
78
}
50
79
51
80
$ dom = new DOMDocument ("1.0 " );
52
81
$ dom ->preserveWhiteSpace = false ;
53
82
$ dom ->formatOutput = true ;
54
83
$ dom ->loadXML ($ result ->asXML ());
55
84
file_put_contents ($ outputFile , $ dom ->saveXML ());
85
+
86
+ printPlainReport ($ plainResult , $ plainReportFile );
56
87
} catch (\Exception $ e ) {
57
88
fwrite (STDERR , $ e ->getMessage () . "\n" );
58
89
exit (1 );
@@ -89,3 +120,24 @@ function getDeviation(array $mainlineResults, array $branchResults)
89
120
{
90
121
return 100 * (getMeanValue ($ branchResults ) / getMeanValue ($ mainlineResults ) - 1 );
91
122
}
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