Non-zero CPU usage when using threads
Adrien <[email protected]> Mon, 21 Dec 2009 00:47:13 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I've been surprised to see my app use 1% - 2% of my CPU. I've reduced
the test case down to:
let () = GtkThread.main ()
Compiled with:
ocamlcp -I /ocaml/lib/ocaml/std-lib/threads -I
/ocaml/lib/ocaml/pkg-lib/lablgtk2 unix.cma threads.cma lablgtk.cma
gtkThread.cmo -p a cpu.ml
I found that by editing gtkThread.ml, I could lower the cpu usage:
- Thread.delay 0.001;
+ Thread.delay 0.013;
I've put a local copy of gtkThread.ml with the aforementioned change
in my code (I'm not sure it's ok license-wise but currently caravel's
license is almost left unspecified) [1]. I'd like comments on this:
how is it, any good/better solution?
[1] http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=caravel/caravel.git;a=commitdiff;h=81e7a6c32dcc72eadb4233f7d08b1d5885a455c8