44
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % PRINT_UTP_RESULTS prints the results structure to a string.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson 07-08-08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: print_utp_results.m,v 1.5 2011/04/17 05:42:54 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 function res = print_utp_results(results)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 DISP_ALL = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 DISP_RUNTIME = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 DISP_RUNTIME_NUM = 30;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 ntests = numel(results);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 apassed = sum([results(:).a]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 spassed = sum([results(:).s]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 res = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 if DISP_ALL
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 res = [res sprintf('\n\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 res = [res sprintf('------------- SUMMARY -------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 res = [res sprintf('UTP name | Syntax | Algorithm\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 for aa=1:ntests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 str = dispRes(results(aa).fcn, results(aa).s, results(aa).a, results(aa).msg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 res = [res str];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 res = [res sprintf('\n\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 if DISP_RUNTIME
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 runtime = [0 results(:).runtime];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 d = diff(runtime);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 [sorted, idx] = sort(d);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 res = [res sprintf('------------- RUNTIME -------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 res = [res sprintf('UTP name | Runtime \n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 for ll = 0:min(DISP_RUNTIME_NUM, length(idx)-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 currentIdx = idx(end-ll);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 str = dispRes(results(currentIdx).fcn, sorted(end-ll), '', '');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 res = [res str];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 res = [res sprintf('\n\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 res = [res sprintf('------------- FAILURES ------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 res = [res sprintf('UTP name | Syntax | Algorithm\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 for jj=1:ntests
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 if results(jj).a==0 || results(jj).s==0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 str = dispRes(results(jj).fcn, results(jj).s, results(jj).a, results(jj).msg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 res = [res str];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 res = [res sprintf('-------------------------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 res = [res sprintf('\n\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 % Summary
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 res = [res sprintf('------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 res = [res sprintf('Total # tests: %d\n', ntests)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 res = [res sprintf('S tests failed: %d\n', ntests - spassed)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 res = [res sprintf('A tests failed: %d\n', ntests - apassed)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 res = [res sprintf('------------------------------------\n')];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 function str = dispRes(fcn, s, a, msg)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 if numel(fcn) > 35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 fcn = [fcn(1:31), ' ...'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 str = sprintf('%-36s%s %s %s\n', fcn, res2str(s), res2str(a), msg);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 function str = res2str(a)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 if islogical(a)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 if (a)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 str = ' pass ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 str = '--fail--';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 elseif isnumeric(a)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 str = sprintf('%8.2f seconds', a);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 elseif ischar(a)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 str = a;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 str = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 end
|