Version française
Home     About     Download     Resources     Contact us    
Browse thread
Thread library (and camlimages)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gregory Guyomarc'h <g_r_e_g_@h...>
Subject: Thread library (and camlimages)
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.