Message-ID: <431D8AA6.20102 at laposte.net> Date: Tue, 06 Sep 2005 14:25:10 +0200 From: Matthieu Dubuget Reply-To: matthieu.dubuget at laposte.net MIME-Version: 1.0 To: lablgtk at math.nagoya-u.ac.jp Subject: Timeout (windows/linux comparison) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I'm trying to draw fast curves on screen using a drawing area from lablgtk2. I experienced very low frequencies under windows. I did a very small (and dirty) program, and ran it in bytecode version on windows and linux in order to understand better my problem. It appears that on windows : - the timeout is different from the expected one - there is a maximum (at about 60 Hz) of the frequency at which I can have a timeout work. The program just increments an int ref inside the timeout function, and prints the frequency obtained when the program stops. Here are my results. asked frequency windows linux 10 9.1 10 20 16 19.9 30 31.1 39.7 80 60.2 82.6 120 62.1 123.9 160 63.8 165.0 200 63.9 198.0 250 62.4 247.3 320 63.9 329.8 I do not know if this is due to the windows implementation of the gimp library managing this part or if the results on windows can be improved by modifying some setting? This surely is not one lablgtk problem, but maybe, someone here has an idea? Thanks in advance Matthieu Dubuget _______________________________ (* ocamlc -dtypes -I +lablgtk2 unix.cma lablgtk.cma gtkInit.cmo tmt.ml -o tmt *) open GMain let main freq duration () = let compteur = ref 0 in let t0 = Unix.gettimeofday () in let window = GWindow.window ~border_width: 10 () in let _ = window#connect#destroy ~callback:(fun () -> let t1 = Unix.gettimeofday () in Printf.printf "%.1f Hz\n" ( float !compteur /. (t1 -. t0 )) ) in let _ = window#connect#destroy ~callback:Main.quit in let vbx = GPack.vbox ~packing:window#add () in let quit = GButton.button ~label:"Quit" ~packing:vbx#add () in let _ = quit#connect#clicked ~callback:window#destroy in let timeout _ = compteur := succ !compteur; if Unix.gettimeofday () -. t0 > (float duration) then begin window # destroy () end; true in let _ = Timeout.add ~ms:(truncate (1000. /. (float freq))) ~callback:timeout in let _ = window#show () in Main.main () let _ = main (int_of_string Sys.argv.(1)) (int_of_string Sys.argv.(2)) () _______________________________