Fetching contributors…
Cannot retrieve contributors at this time
68 lines (59 sloc) 1.73 KB
Copyright © 2011 MLstate
This file is part of Opa.
Opa is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
Opa is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with Opa. If not, see <>.
@author Adam Koprowski
(** Parses a list of Opa files taken from stdin & prints some basic timing info *)
let measureTime f =
let startT = Sys.time () in
let res = f () in
let endT = Sys.time () in
res, endT -. startT
let opa_parse fn =
let go () =
let _ = OpaParser.parse_file fn in
e -> false
Printf.eprintf "Parsing %s... %!" fn;
let res, t = measureTime go in
Printf.eprintf "%s (%4.2fs.)%!\n" (if res then "OK" else "FAIL") t;
let _ =
let inc = stdin in
let rec file_list () =
let fn = input_line inc in
fn :: file_list ()
End_of_file -> []
let files = file_list () in
let total = List.length files in
let rec go n files () =
match files with
| [] -> 0
| fn::fns ->
Printf.eprintf "[%4d/%4d] " n total;
let success = opa_parse fn in
let res = go (n + 1) fns () in
if success then
res + 1
let fail, t = measureTime (go 1 files) in
Printf.eprintf "Total time of parsing %d files [%d failures]: %4.2fsec.\n" total fail t