Browse thread
[Caml-list] Generation of streams is slow
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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
time?
Alexander
open Printf
let gen_stream n =
let rec gs i n =
if i = n then [< 'n >] else [< 'i; (gs (i+1) n) >]
in
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
end
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