List Info

Thread: "ocaml_beginners"::[] Performance questions




"ocaml_beginners"::[] Performance questions
country flaguser name
United States
2007-06-11 10:11:46

Hi

Two questions:

Does it make a difference in performance when I:

1) implement a loop using 'while' vs tail recursion?

2) set a field of a record to be mutable vs non-mutable? Why?

Thanks
Raj

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Performance questions
country flaguser name
United Kingdom
2007-06-11 12:36:24

On Mon, Jun 11, 2007 at 10:11:46AM -0500, Raj B wrote:
> Hi
>
> Two questions:
>
> Does it make a difference in performance when I:
>
> 1) implement a loop using 'while' vs tail recursion?
>
> 2) set a field of a record to be mutable vs non-mutable? Why?

This sounds like a university course question. Do you have some code
or a more specific statement of the problem you're trying to solve?

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Performance questions
country flaguser name
France
2007-06-11 13:39:40

Le Mon, 11 Jun 2007 10:11:46 -0500, Raj B < rajb%40rice.edu">rajbrice.edu&gt; a écrit :
> Does it make a difference in performance when I:
>
> 1) implement a loop using 'while' vs tail recursion?

At least in the case of arrays, yes.

I can't find the link anymore but you should browse the caml website
(http://caml.inria.fr), there's a page about this problem (and others).

Sincerely,
--
Gabriel Kerneis

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Performance questions
country flaguser name
Belgium
2007-06-11 13:55:58

On Mon, 11 Jun 2007, Raj B < rajb%40rice.edu">rajbrice.edu&gt; wrote:
&gt;
> Does it make a difference in performance when I:
> 1) implement a loop using 'while' vs tail recursion?
> 2) set a field of a record to be mutable vs non-mutable? Why?

You can supplement your answers with real data ! Write code for both
and time it : http://ocaml-benchmark.sourceforge.net/

ChriS

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] Performance questions
country flaguser name
United Kingdom
2007-06-11 13:54:49

On Monday 11 June 2007 16:11:46 Raj B wrote:
&gt; Hi
>
> Two questions:
>
&gt; Does it make a difference in performance when I:

These are tough questions. You can really only expect an accurate answer from
INRIA but I'll try:

> 1) implement a loop using 'while' vs tail recursion?

I believe floats will not be unboxed across recursive function calls, even
tail recursive ones. So "while" can be faster.

> 2) set a field of a record to be mutable vs non-mutable? Why?

I believe the compiler and run-time can exploit immutability to improve
efficiency.

Sorry I can't give you anything more specific but I'm afraid it would be wrong
or at least misleading.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e

__._,_.___
.

__,_._,___
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )