aboutsummaryrefslogtreecommitdiff
path: root/judge/main.ml
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-11-13 18:20:40 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-11-13 18:20:40 +0100
commit69b66557a8bfef7cc4d96fde120d0360f5a94d8b (patch)
tree9f290eedd788e114d19f4d33c7fb3873fdb1591a /judge/main.ml
parent773dcc7eb40f270a7eb8003678b05943508e9a73 (diff)
downloadCompetIA-69b66557a8bfef7cc4d96fde120d0360f5a94d8b.tar.gz
CompetIA-69b66557a8bfef7cc4d96fde120d0360f5a94d8b.zip
Improve performance by removing useless GUI updates.
Diffstat (limited to 'judge/main.ml')
-rw-r--r--judge/main.ml19
1 files changed, 13 insertions, 6 deletions
diff --git a/judge/main.ml b/judge/main.ml
index 47d29ba..38de615 100644
--- a/judge/main.ml
+++ b/judge/main.ml
@@ -11,7 +11,7 @@ module UI (C : CORE) : sig
val init : unit -> unit
val close : unit -> unit
- val handle_events : unit -> unit
+ val handle_events : unit -> bool
val display : unit -> unit
end = struct
@@ -41,7 +41,9 @@ end = struct
| Question of string * (unit -> unit) * view
let rec handle_events () =
+ let usefull = ref false in
while key_pressed () do
+ usefull := true;
match !curr_view, read_key() with
| ScoreBoard, '\t' -> curr_view := MatchList false
| MatchList _, '\t' -> curr_view := ScoreBoard
@@ -88,7 +90,8 @@ end = struct
raise Exit_judge),
v)
| _ -> ()
- done
+ done;
+ !usefull
and display () =
clear_graph ();
@@ -222,12 +225,16 @@ end = struct
module UI = UI(C)
let run () =
- C.init();
UI.init();
+ C.init();
+ let last_r = ref 0.0 in
begin try while true do
- C.handle_events ();
- UI.handle_events ();
- UI.display ()
+ let a = C.handle_events () in
+ let b = UI.handle_events () in
+ if a || b || Unix.gettimeofday() -. !last_r > 0.1 then begin
+ UI.display ();
+ last_r := Unix.gettimeofday()
+ end
done with
Exit_judge ->
C.finish ();