caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Thread library (and camlimages)
@ 2005-04-10  3:30 Gregory Guyomarc'h
  0 siblings, 0 replies; only message in thread
From: Gregory Guyomarc'h @ 2005-04-10  3:30 UTC (permalink / raw)
  To: caml-list

Hello everyone,

I don't understand the performance of a program that uses camlimages along 
with the thread library, also I don't really understand why the program 
throws an exception in the 3rd case (see below).

I compiled the program with the following options:

ocamlopt -version
3.08.3
ocamlopt -thread -I +threads -I ~/dev/godi/lib/ocaml/pkg-lib/camlimages -c 
test.ml
ocamlopt -thread -I +threads -I ~/dev/godi/lib/ocaml/pkg-lib/camlimages 
unix.cmxa threads.cmxa ci_core.cmxa ci_bmp.cmxa test.cmx -o test.opt

>>Beginning of test.ml

open OImages

(* LINE1 *) let _ = Printf.printf "Thread: %d\n" (Thread.id (Thread.self 
()))

(* LINE2 *) let dummy () = Thread.delay 0.001

let files = ref []

let _ = Arg.parse [] (fun s -> files := s :: !files) ""

let load_image file =
  Printf.printf "Loading image: %s\n" file; flush stdout;
  let image =
    try
      match tag (OImages.load file []) with
        | Rgb24   i -> i
        | Index8  i -> i#to_rgb24
        | Index16 i -> i#to_rgb24
        | _ -> failwith "unsupported image file format"
    with
      | e -> prerr_endline (Printexc.to_string e); raise e
  in image;
;;

let images = List.map load_image (List.rev !files)

<< End of test.ml



Case 1, with LINE1 and LINE2:

time ./test.opt image.0[1-9].bmp

real	0m8.129s
user   0m8.103s
sys	0m0.019s



Case 2, without LINE1 and without lINE2:

time ./test.opt image.0[1-9].bmp

real	0m0.440s
user   0m0.381s
sys	0m0.019s



Case 3, with LINE1 and without LINE2:

time ./test.opt image.0[1-9].bmp
Thread: Fatal error: exception Invalid_argument("Thread.self: not 
initialized")



Any idea about what's going on here ?

Thanks.
Gregory Guyomarc'h.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-10  3:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-10  3:30 Thread library (and camlimages) Gregory Guyomarc'h

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).