From: "Frédéric Gava" <frederic.gava@wanadoo.fr>
To: "caml-list" <caml-list@inria.fr>
Subject: Re: [Caml-list] Memory allocation nano-benchmark.
Date: Fri, 11 Feb 2005 00:58:05 +0100 [thread overview]
Message-ID: <01a001c50fcc$5cff2fe0$d54380d9@mshome.net> (raw)
In-Reply-To: <420BBC7D.5070103@t-online.de>
Hi,
There is a function in the stdlid for have a beter code:
let test tablesize =
let table = Array.create tablesize [| [| |] |] in
for i=0 to tablesize - 1 do
table.(i) <- Array.make_matrix tablesize tablesize 0
done;
...
smaller code no ? ;-)
> The results (on an AMD 2000XP):
>
> chris@gentoo:~/test$ ocamlopt -unsafe -inline 40 memnew.ml
> chris@gentoo:~/test$ a.out 300
> chris@gentoo:~/test$ time a.out 300
> real 0m1.560s
> user 0m1.391s
> sys 0m0.105s
>
> chris@gentoo:~/test$ ocamlopt -unsafe -inline 40 mem.ml
> chris@gentoo:~/test$ time a.out 300
> real 0m2.106s
> user 0m1.904s
> sys 0m0.106s
>
> chris@gentoo:~/test$ gcc -O3 -fomit-frame-pointer mem.c
> chris@gentoo:~/test$ time a.out 300
> real 0m0.380s
> user 0m0.283s
> sys 0m0.072s
>
> So, yours is slightly faster, but both are in the same ballpark
> and the C version is at least 4X faster.
:-(
Peraps due to the fact that "int" are boxed. Try to give "options you give
to gcc" to ocamlopt
to link optimized code. Else I do not know how to optimize this code "in a
pure ocaml way" (i.e without trick with C code). Is caml guru, wizards or
ocaml's creators have an idea ?
Regards,
Frédéric Gava
next prev parent reply other threads:[~2005-02-10 23:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-10 15:15 Christian Szegedy
2005-02-10 14:47 ` [Caml-list] " Frédéric Gava
2005-02-10 15:19 ` skaller
2005-02-10 16:36 ` Frédéric Gava
2005-02-10 17:56 ` Frédéric Gava
2005-02-10 19:56 ` Christian Szegedy
2005-02-10 23:58 ` Frédéric Gava [this message]
2005-02-11 9:22 ` Frédéric Gava
2005-02-11 13:04 ` skaller
2005-02-11 13:33 ` skaller
2005-02-11 21:07 ` Oliver Bandel
2005-02-12 0:44 ` skaller
2005-02-15 14:17 ` Frédéric Gava
2005-02-15 19:19 ` Christian Szegedy
2005-02-15 20:51 ` Jon Harrop
2005-02-16 8:19 ` Ville-Pertti Keinonen
2005-02-16 9:54 ` Jon Harrop
2005-02-16 10:56 ` Ville-Pertti Keinonen
2005-02-11 0:55 ` skaller
2005-02-10 14:56 ` Jon Harrop
2005-02-10 15:32 ` Ville-Pertti Keinonen
2005-02-10 14:59 ` John Prevost
2005-02-10 16:50 ` Marwan Burelle
2005-02-10 19:20 ` Christian Szegedy
2005-02-10 19:40 ` Jon Harrop
2005-02-11 11:26 ` Oliver Bandel
2005-02-12 13:42 ` Christian Szegedy
2005-02-11 1:04 ` skaller
2005-02-11 11:28 ` Oliver Bandel
2005-02-12 0:01 ` Guillaume
2005-02-12 0:36 ` skaller
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='01a001c50fcc$5cff2fe0$d54380d9@mshome.net' \
--to=frederic.gava@wanadoo.fr \
--cc=caml-list@inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).