English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Generation of streams is slow
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-07-13 (22:05)
From: Alexander V. Voinov <avv@q...>
Subject: [Caml-list] Generation of streams is slow
Hi All,

I've run the following program and found it to be extremely slow. Why?
Does it mean that streams are worth using only when they are built from
input text channels, and in all other cases they are just a waste of


open Printf

let gen_stream n =
  let rec gs i n =
    if i = n then [< 'n >] else [< 'i; (gs (i+1) n) >]
  gs 1 n

let rec stupid_loop n s =
  if n > 0 then begin
    if n mod 1000 = 0 then (print_char('.'); flush stdout);
    let i = Stream.next s in
    if i <> n then raise (Failure "they don't match");
    stupid_loop (n+1) s
  else 0;;

let _ =
  stupid_loop 1 (gen_stream 100000);;

Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr