test program: -gc option to print GC stats

This commit is contained in:
Simon Cruanes 2014-11-04 20:37:00 +01:00
parent 30e372d302
commit 3107fc4755

View file

@ -9,7 +9,6 @@ let file = ref ""
let p_assign = ref false let p_assign = ref false
let time_limit = ref 300. let time_limit = ref 300.
let size_limit = ref 1000_000_000. let size_limit = ref 1000_000_000.
;;
let int_arg r arg = let int_arg r arg =
let l = String.length arg in let l = String.length arg in
@ -32,7 +31,11 @@ let int_arg r arg =
| '0'..'9' -> r := float_of_string arg | '0'..'9' -> r := float_of_string arg
| _ -> raise (Arg.Bad "bad numeric argument") | _ -> raise (Arg.Bad "bad numeric argument")
with Failure "float_of_string" -> raise (Arg.Bad "bad numeric argument") with Failure "float_of_string" -> raise (Arg.Bad "bad numeric argument")
;;
let setup_gc_stat () =
at_exit (fun () ->
Gc.print_stat stdout;
)
let input_file = fun s -> file := s let input_file = fun s -> file := s
let usage = "Usage : main [options] <file>" let usage = "Usage : main [options] <file>"
@ -44,7 +47,9 @@ let argspec = Arg.align [
"-s", Arg.String (int_arg size_limit), "-s", Arg.String (int_arg size_limit),
"<s>[kMGT] Sets the size limit for the sat solver"; "<s>[kMGT] Sets the size limit for the sat solver";
"-model", Arg.Set p_assign, "-model", Arg.Set p_assign,
" Outputs the boolean model found if sat"; "Outputs the boolean model found if sat";
"-gc", Arg.Unit setup_gc_stat,
"Outputs statistics about the GC";
] ]
(* Limits alarm *) (* Limits alarm *)
@ -86,7 +91,7 @@ let main () =
Arg.usage argspec usage; Arg.usage argspec usage;
exit 2 exit 2
end; end;
let al = Gc.create_alarm check in ignore(Gc.create_alarm check);
(* Interesting stuff happening *) (* Interesting stuff happening *)
let cnf = get_cnf () in let cnf = get_cnf () in
@ -98,14 +103,14 @@ let main () =
print_assign Format.std_formatter () print_assign Format.std_formatter ()
| S.Unsat -> | S.Unsat ->
Format.printf "Unsat@." Format.printf "Unsat@."
;;
try let () =
try
main () main ()
with with
| Out_of_time -> | Out_of_time ->
Format.printf "Time limit exceeded@."; Format.printf "Time limit exceeded@.";
exit 2 exit 2
| Out_of_space -> | Out_of_space ->
Format.printf "Size limit exceeded@."; Format.printf "Size limit exceeded@.";
exit 3 exit 3