| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open BenchUtil |
| 12 |
|
| 13 |
let time_regex = Str.regexp {|^Chars \([0-9]+\) - \([0-9]+\) [^ ]+ \([0-9.]+\) secs|} |
| 14 |
|
| 15 |
let rec parse_loop filech acc = |
| 16 |
match input_line filech with |
| 17 |
| exception End_of_file -> |
| 18 |
List.rev acc |
| 19 |
| l -> |
| 20 |
if not (Str.string_match time_regex l 0) then |
| 21 |
parse_loop filech acc |
| 22 |
else |
| 23 |
let b = int_of_string @@ Str.matched_group 1 l |
| 24 |
and e = int_of_string @@ Str.matched_group 2 l |
| 25 |
and t = Str.matched_group 3 l in |
| 26 |
let v = { start_char = b; stop_char = e; }, { str = t; q = Q.of_string t } in |
| 27 |
parse_loop filech (v :: acc) |
| 28 |
|
| 29 |
let parse ~file = |
| 30 |
let ch = open_in file in |
| 31 |
let v = parse_loop ch [] in |
| 32 |
close_in ch; |
| 33 |
v |