1 (* This is for processing information created with the -profile_iso option.
2 Runs are assumed separated with a line beginning with =.
3 The first run is discarded *)
5 let is_marker l
= String.get l
0 = '
='
6 let is_nothing l
= String.sub l
0 2 = "ls"
8 let skip_start i
= (* skip over the ========== at the beginning *)
10 let l = input_line i
in
16 match Str.split
(Str.regexp
":") l with
18 (match Str.split
(Str.regexp
" sec") after
with
19 [info
;_
] -> float_of_string info
20 | _
-> failwith
"bad data")
21 | _
-> failwith
(Printf.sprintf
"bad data %s" l)
23 type more
= MORE
| NOMORE
| INFO
of float * float * float * float | CONT
27 let start = input_line i
in (* three lines of header *)
30 else if is_nothing start
33 let _ = input_line i
in
34 let _ = input_line i
in
37 [input_line i
;input_line i
;input_line i
;input_line i
]
39 [asttoctl
;full_engine
;mysat
;parse_cocci
] ->
40 if String.get full_engine
0 = '
*'
41 then (let _ = input_line i
in CONT
) (* hack!!! *)
43 let asttoctl = get_data asttoctl in
44 let full_engine = get_data full_engine in
45 let mysat = get_data mysat in
46 let parse_cocci = get_data parse_cocci in
47 INFO
(full_engine,mysat,parse_cocci,asttoctl)
48 | _ -> failwith
"not possible")
49 with End_of_file
-> NOMORE
53 let optcons x y
= if x
= [] then y
else x
::y
in
54 let rec loop all_acc acc
=
55 match read_data_one i
with
56 NOMORE
-> optcons acc all_acc
57 | MORE
-> loop (optcons acc all_acc
) []
58 | CONT
-> loop all_acc acc
59 | INFO
(a
,b
,c
,d
) -> loop all_acc
((a
,b
,c
,d
)::acc
) in
60 let table = loop [] [] in
61 let all_infos = (* a list with a list of information for each file *)
63 (function all_infos ->
65 List.map2
(function ainfo
-> function orun
-> orun
::ainfo
)
67 (List.map
(function _ -> []) (List.hd
table))
71 (List.map
(List.map
(function (_,x
,y
,z
) -> x
+.y
+.z
)) all_infos) in
74 (List.map
(List.map
(function (x
,_,_,_) -> x
)) all_infos) in
77 (List.map
(List.map
(function (_,x
,_,_) -> x
)) all_infos) in
80 (List.map
(List.map
(function (_,_,x
,y
) -> x
+. y
)) all_infos) in
81 (overheads,total_times,mysat_times,parse_time)
83 let percent pct
= (int_of_float
((100.0 *. pct
) +. 0.5)) - 100
84 let mpercent pct
= (int_of_float
((100.0 *. pct
) +. 0.5))
85 let minf l = List.fold_left min
(List.hd
l) l
86 let maxf l = List.fold_left max
(List.hd
l) l
91 let total = List.fold_left
(+.) 0.0 l in
92 total /. (float_of_int
(List.length
l))
94 let process_files iso_file noiso_file
=
95 let i = open_in iso_file
in
96 let (iso_over
,iso_total
,iso_mysat
,iso_parse
) = read_data i in
98 let i = open_in noiso_file
in
99 let (noiso_over
,noiso_total
,noiso_mysat
,noiso_parse
) = read_data i in
101 Printf.printf
"isos: min %f max %f ave %f\n"
102 (minf iso_total
) (maxf iso_total
) (ave iso_total
);
103 Printf.printf
"noisos: min %f max %f ave %f\n"
104 (minf noiso_total
) (maxf noiso_total
) (ave noiso_total
);
105 Printf.printf
"Overhead in total time %d%%: min %f max %f\n"
106 (percent (ave (List.map2
(/.) iso_total noiso_total
)))
107 (minf (List.map2
(-.) iso_total noiso_total
))
108 (maxf (List.map2
(-.) iso_total noiso_total
));
109 Printf.printf
"Portion of overhead due to parsing %d%%: min %f max %f\n"
111 (ave (List.fold_left2
113 (function (iso_total
,iso_parse
) ->
114 (function (noiso_total
,noiso_parse
) ->
115 let total_ovd = iso_total
-. noiso_total
in
116 let parse_ovd = iso_parse
-. noiso_parse
in
117 if total_ovd < 0.001 or parse_ovd > total_ovd or
120 else (parse_ovd /. total_ovd) :: acc
)))
122 (List.combine iso_total iso_parse
)
123 (List.combine noiso_total noiso_parse
))))
124 (minf (List.map2
(-.) iso_parse noiso_parse
))
125 (maxf (List.map2
(-.) iso_parse noiso_parse
));
126 Printf.printf
"Portion of overhead due to matching %d%%: min %f max %f\n\n"
128 (ave (List.fold_left2
130 (function (iso_total
,iso_mysat
) ->
131 (function (noiso_total
,noiso_mysat
) ->
132 let total_ovd = iso_total
-. noiso_total
in
133 let mysat_ovd = iso_mysat
-. noiso_mysat
in
134 if total_ovd < 0.001 or mysat_ovd > total_ovd or
137 else (mysat_ovd /. total_ovd) :: acc
)))
139 (List.combine iso_total iso_mysat
)
140 (List.combine noiso_total noiso_mysat
))))
141 (minf (List.map2
(-.) iso_mysat noiso_mysat
))
142 (maxf (List.map2
(-.) iso_mysat noiso_mysat
))
145 let iso = Array.get
Sys.argv
1 in
146 let noiso = Array.get
Sys.argv
2 in
147 process_files iso noiso