*)
let trust = true
+let deadline = 30
let conffile = "../../../matita/matita.conf.xml"
let _ = CicEnvironment.set_trust (fun _ -> trust);;
Printf.printf "Old: %.2f (%.2f%%)\n" !old_total (perc !new_total !old_total))
;;
+let timeout = ref false;;
+
+let _ =
+ Sys.set_signal 14 (* SIGALRM *)
+ (Sys.Signal_handle (fun _ ->
+ timeout := true;
+ raise Sys.Break))
+;;
+
let urifname =
try
Sys.argv.(1)
Printf.printf "%s " uri;
flush stdout;
let uri = UriManager.uri_of_string uri in
- let before = Unix.gettimeofday () in
- ignore (CicTypeChecker.typecheck uri);
- let after = Unix.gettimeofday () in
- let diff = after -. before in
+ let obj,_ = CicEnvironment.get_obj CicUniv.empty_ugraph uri in
+ ignore (Unix.alarm deadline);
+ CicTypeChecker.typecheck_obj uri obj;
+ ignore (Unix.alarm 0);
+ CicEnvironment.remove_obj uri;
+ let before = Unix.times () in
+ ignore (Unix.alarm deadline);
+ ignore (CicTypeChecker.typecheck_obj uri obj);
+ ignore (Unix.alarm 0);
+ let memusage = (Gc.stat ()).Gc.live_words * 4 / 1024 / 1024 in
+ if memusage > 500 then
+ begin
+ prerr_endline ("MEMORIA ALLOCATA: " ^ string_of_int memusage ^ "Mb");
+ CicEnvironment.empty ();
+ Gc.compact ();
+ let memusage = (Gc.stat ()).Gc.live_words * 4 / 1024 / 1024 in
+ prerr_endline ("DOPO CicEnvironment.empty: " ^ string_of_int memusage ^ "Mb");
+ end;
+ let after = Unix.times () in
+ let diff = after.Unix.tms_utime +. after.Unix.tms_stime -. before.Unix.tms_utime -. before.Unix.tms_stime in
new_total := !new_total +. diff;
Printf.printf "\e[0;32mOK\e[0m %.2f" diff;
(match time with
begin
Printf.printf "\e[0;31mSKIPPED\e[0m\n";
flush stdout;
- Printf.eprintf "\e[0;31mContinue with next URI? [y/_]\e[0m";
- flush stderr;
+ if not !timeout then
+ begin
+ Printf.eprintf "\e[0;31mContinue with next URI? [y/_]\e[0m";
+ flush stderr;
+ end;
end;
- (match input_line stdin with
- "y" -> ()
- | _ -> raise Done)
+ if not !timeout then
+ (match input_line stdin with
+ "y" -> ()
+ | _ -> raise Done)
+ else
+ timeout := false
with
Sys.Break -> skip_break false
in
skip_break true
+ | CicEnvironment.CircularDependency _ ->
+ Printf.printf "\e[0;31mCIRCULARDEP\e[0m\n"
| exn ->
Printf.printf "\e[0;31mFAIL\e[0m\n";
flush stdout;