caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel M. Albro" <albro@humnet.ucla.edu>
To: fabrice@lefessant.net
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Loop times
Date: Mon, 17 Mar 2003 10:59:27 -0800	[thread overview]
Message-ID: <3E761B0F.8050303@humnet.ucla.edu> (raw)
In-Reply-To: <15989.46038.984076.710373@lachesis.inria.fr>


OK, I did this test, but first after making the thing
compatible with the other tests I did.  (That is, the
j loop should be 0 to 9 (or some other number less than
12 and greater than 4).  The first version (once
again, after changing the j loop to 0 to 9) takes

real    0m34.033s
user    0m34.030s
sys     0m0.000s

and Fabrice's version (with 0 to 9) takes

real    0m28.086s
user    0m28.080s
sys     0m0.000s

so it is definitely a win.

					- Dan

Fabrice Le Fessant wrote:
>> 
>> 	OK, I just did a test of the three methods.  Here's the code:
>> 
>> Exception Version:
>> -------------------------------------------------
>> exception Break
>> 
>> let _ =
>>   let ary = [|1;2;3;4;5;6;7;8;9;10;11;12|] in
>>     for i = 1 to 1_000_000_000 do
>>       try
>>         for j = 1 to 10 do
>>           if ary.(j) = 5 then
>>             raise Break
>>         done
>>       with Break -> ()
>>     done
>> 
>> real    0m30.569s
>> user    0m30.250s
>> sys     0m0.140s
>> ------------------------------------------------------
> 
> 
> For the fun, could you try this one ? It does not allocate the
> exception in the loop but outside.
> 
>   -------------------------------------------------
>  exception Break
>  
>  let _ =
>    let ary = [|1;2;3;4;5;6;7;8;9;10;11;12|] in
>    let exn = Break in
>      for i = 1 to 1_000_000_000 do
>        try
>          for j = 1 to 10 do
>            if ary.(j) = 5 then
>              raise exn
>          done
>        with Break -> ()
>      done 
>  ------------------------------------------------------
>  
> 
> 
> - Fabrice
> 


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-03-17 19:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-13 21:53 Daniel M. Albro
2003-03-17 11:39 ` Fabrice Le Fessant
2003-03-17 18:59   ` Daniel M. Albro [this message]
     [not found]     ` <20030317214841.GA467@first.in-berlin.de>
2003-03-17 22:01       ` Daniel M. Albro
2003-03-18  9:57         ` Oliver Bandel
2003-03-18  8:52 Oliver Bandel
2003-03-18 15:21 ` Florian Hars
2003-03-18 15:40 ` Noel Welsh
2003-03-19  6:48 ` Daniel M. Albro

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=3E761B0F.8050303@humnet.ucla.edu \
    --to=albro@humnet.ucla.edu \
    --cc=caml-list@inria.fr \
    --cc=fabrice@lefessant.net \
    /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).