4 val print_parsing_stat_list: parsing_stat list -> unit
7 (*****************************************************************************)
9 (*****************************************************************************)
12 mutable have_timeout
: bool;
17 mutable commentized
: int; (* by our cpp commentizer *)
19 (* if want to know exactly what was passed through, uncomment:
21 * mutable passing_through_lines: int;
23 * it differs from bad by starting from the error to
24 * the synchro point instead of starting from start of
25 * function to end of function.
30 let default_stat file
= {
37 (* todo: stat per dir ? give in terms of func_or_decl numbers:
38 * nbfunc_or_decl pbs / nbfunc_or_decl total ?/
40 * note: cela dit si y'a des fichiers avec des #ifdef dont on connait pas les
41 * valeurs alors on parsera correctement tout le fichier et pourtant y'aura
42 * aucune def et donc aucune couverture en fait.
43 * ==> TODO evaluer les parties non parsé ?
46 let print_parsing_stat_list ?
(verbose
=false) = fun statxs
->
47 let total = List.length statxs
in
50 +> List.filter
(function
51 {have_timeout
= false; bad
= 0} -> true | _
-> false)
56 pr
"\n\n\n---------------------------------------------------------------";
59 +> List.filter
(function
60 | {have_timeout
= true} -> true
61 | {bad
= n
} when n
> 0 -> true
63 +> List.iter
(function
64 {filename
= file
; have_timeout
= timeout
; bad
= n
} ->
65 pr
(file ^
" " ^
(if timeout
then "TIMEOUT" else i_to_s n
));
69 pr
"files with lots of tokens passed/commentized:";
70 let threshold_passed = 100 in
72 +> List.filter
(function
73 | {commentized
= n
} when n
> threshold_passed -> true
75 +> List.iter
(function
76 {filename
= file
; commentized
= n
} ->
77 pr
(file ^
" " ^
(i_to_s n
));
80 pr
"\n\n\n---------------------------------------------------------------";
84 (sprintf
"NB total files = %d; " total) ^
85 (sprintf
"perfect = %d; " perfect) ^
86 (sprintf
"pbs = %d; " (statxs
+> List.filter
(function
87 {have_timeout
= b
; bad
= n
} when n
> 0 -> true | _
-> false)
89 (sprintf
"timeout = %d; " (statxs
+> List.filter
(function
90 {have_timeout
= true; bad
= n
} -> true | _
-> false)
92 (sprintf
"=========> %d" ((100 * perfect) / total)) ^
"%"
95 let good = statxs
+> List.fold_left
(fun acc
{correct
= x
} -> acc
+x
) 0 in
96 let bad = statxs
+> List.fold_left
(fun acc
{bad = x
} -> acc
+x
) 0 in
97 let passed = statxs
+> List.fold_left
(fun acc
{commentized
= x
} -> acc
+x
) 0
99 let gf, badf
= float_of_int
good, float_of_int
bad in
100 let passedf = float_of_int
passed in
102 (sprintf
"nb good = %d, nb passed = %d " good passed) ^
103 (sprintf
"=========> %f" (100.0 *. (passedf /. gf)) ^
"%")
106 (sprintf
"nb good = %d, nb bad = %d " good bad) ^
107 (sprintf
"=========> %f" (100.0 *. (gf /. (gf +. badf
))) ^
"%"
111 (*****************************************************************************)
113 (*****************************************************************************)
115 (* coupling: if you add a new var, modify also assoc_stat_number below *)
117 let nTypedefInfer = ref 0
119 let nIncludeGrammar = ref 0
120 let nIncludeHack = ref 0
122 let nIteratorGrammar = ref 0
123 let nIteratorHeuristic = ref 0
125 let nMacroTopDecl = ref 0
126 let nMacroStructDecl = ref 0
127 let nMacroDecl = ref 0
128 let nMacroStmt = ref 0
129 let nMacroString = ref 0
130 let nMacroHigherOrder = ref 0 (* actions *)
131 let nMacrohigherTypeGrammar = ref 0
132 let nMacroAttribute = ref 0
134 let nIfdefTop = ref 0
135 let nIfdefStmt = ref 0
136 let nIfdefStruct = ref 0
137 let nIfdefInitializer = ref 0
138 (* nIfdefExpr, nIfdefType *)
140 let nIfdefFunheader = ref 0
142 let nIfdefExprPassing = ref 0
143 let nIfdefPassing = ref 0
145 let nIncludePassing = ref 0
146 let nDefinePassing = ref 0
148 let nIfdefZero = ref 0
149 let nIfdefVersion = ref 0
153 let nGccTypeof = ref 0
154 let nGccLongLong = ref 0
156 let nGccInline = ref 0
157 let nGccAttribute = ref 0
158 let nGccCaseRange = ref 0
159 let nGccMixDecl = ref 0
160 let nGccDesignator = ref 0
161 let nGccStmtExpr = ref 0
162 let nGccConstructor = ref 0
163 let nGccEmptyStruct = ref 0
164 let nGccNestedFunc = ref 0
170 let nDefineHack = ref 0
172 let nDefineConstant = ref 0
173 let nDefineStmt = ref 0
174 let nDefineExpr = ref 0
175 (* both below require some heuristic support *)
176 let nDefineWhile0 = ref 0
177 let nDefineInit = ref 0
179 let nDefineOther = ref 0
182 let nPragmaAndCo = ref 0
184 (* let nDirectiveTop = ref 0 *)
185 let nDirectiveStmt = ref 0
186 let nDirectiveStruct = ref 0
187 let nDirectiveInitializer = ref 0
190 (* from standard.h *)
191 let nMacroHint = ref 0
192 let nMacroExpand = ref 0
194 let nNotParsedCorrectly = ref 0
196 let assoc_stat_number =
198 "nTypedefInfer", nTypedefInfer;
200 "nIteratorHeuristic", nIteratorHeuristic;
202 "nMacroTopDecl", nMacroTopDecl;
203 "nMacroStructDecl", nMacroStructDecl;
204 "nMacroDecl", nMacroDecl;
205 "nMacroStmt", nMacroStmt;
206 "nMacroString", nMacroString;
207 "nMacroHigherOrder", nMacroHigherOrder;
208 "nMacroAttribute", nMacroAttribute;
210 "nMacrohigherTypeGrammar", nMacrohigherTypeGrammar;
212 "nIfdefTop", nIfdefTop;
213 "nIfdefStmt", nIfdefStmt;
214 "nIfdefStruct", nIfdefStruct;
215 "nIfdefInitializer", nIfdefInitializer;
217 "nIfdefFunheader", nIfdefFunheader;
218 "nIfdefZero", nIfdefZero;
219 "nIfdefVersion", nIfdefVersion;
220 "nIfdefExprPassing", nIfdefExprPassing;
221 "nIfdefPassing", nIfdefPassing;
223 "nIncludePassing", nIncludePassing;
224 "nDefinePassing", nDefinePassing;
226 "nMacroExpand", nMacroExpand;
227 "nMacroHint", nMacroHint;
230 "nGccTypeof", nGccTypeof;
231 "nGccLongLong", nGccLongLong;
233 "nGccInline", nGccInline;
234 "nGccAttribute", nGccAttribute;
235 "nGccCaseRange", nGccCaseRange;
236 "nGccMixDecl", nGccMixDecl;
237 "nGccDesignator", nGccDesignator;
238 "nGccStmtExpr", nGccStmtExpr;
239 "nGccConstructor", nGccConstructor;
240 "nGccEmptyStruct", nGccEmptyStruct;
241 "nGccNestedFunc", nGccNestedFunc;
243 "nGccMisc", nGccMisc;
246 "nDefineHack", nDefineHack;
248 "nDefineConstant", nDefineConstant;
249 "nDefineStmt", nDefineStmt;
250 "nDefineExpr", nDefineExpr;
251 "nDefineInit", nDefineInit;
252 "nDefineOther", nDefineOther;
255 "nPragmaAndCo", nPragmaAndCo;
257 "nDirectiveStmt", nDirectiveStmt;
258 "nDirectiveStruct", nDirectiveStruct;
259 "nDirectiveInitializer", nDirectiveInitializer;
261 "nNotParsedCorrectly", nNotParsedCorrectly;
265 "nIncludeGrammar", nIncludeGrammar;
266 "nIncludeHack", nIncludeHack;
268 "nIteratorGrammar", nIteratorGrammar;
271 let print_stat_numbers () =
272 assoc_stat_number +> List.iter
(fun (k
, vref
) ->
273 pr2
(spf
"%-30s -> %d" k
!vref
);