From: "Vladimir N. Silyaev" <vsilyaev@mindspring.com>
To: caml-list@inria.fr
Cc: Kenneth Knowles <kknowles@berkeley.edu>
Subject: [Caml-list] Lazy vs closure
Date: Tue, 18 May 2004 23:21:57 -0700 [thread overview]
Message-ID: <20040519062157.GA65076@server.vns.oc.ca.us> (raw)
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
After reading list and seeing statement that lazy/Lazy.force is faster then
closure/apply, I've decided to run microbenchmark with both.
Results are rather confusing:
Byte code - Lazy is three times slower than closure
Native code (x86) - it's either coredumps or leaks memory
Code attached as <<lazy.ml>>. With it's current form native code
leaks memory, by uncommenting first two lines it would coredump.
Also both compilers tends to generate rather strange error.
=-=-=-=-=-=
The files lazy.cmi and lazy.cmi make inconsistent assumptions
over interface Lazy
=-=-=-=-=-=
This error fixable by removing lazy.cmi from a disk.
Have I stepped on some known bug/feature?
Vladimir
[-- Attachment #2: lazy.ml --]
[-- Type: text/plain, Size: 490 bytes --]
(* Uncomment me
let l = lazy (1+1)
let _ = Lazy.force l
*)
let fixit = ref 0
let test_lazy n =
let l = lazy (n+1) in
fixit := Lazy.force l
let test_closure n =
let c = (fun _ -> n+1) in
fixit := c ()
let test n test =
let start = Sys.time () in
for i=0 to n do
test i
done;
(Sys.time ()) -. start
let result =
List.map (test 1000000) [test_lazy; test_closure]
let _ = List.iter print_endline (List.map string_of_float result)
next reply other threads:[~2004-05-19 6:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-19 6:21 Vladimir N. Silyaev [this message]
2004-05-19 7:04 ` David Brown
2004-05-19 7:32 ` Vladimir N. Silyaev
2004-05-19 7:59 ` David Brown
2004-05-19 9:10 ` skaller
2004-05-19 13:11 ` Kenneth Knowles
2004-05-19 13:09 ` [Caml-list] " Kenneth Knowles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040519062157.GA65076@server.vns.oc.ca.us \
--to=vsilyaev@mindspring.com \
--cc=caml-list@inria.fr \
--cc=kknowles@berkeley.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox