Re: Real Sequence Related Performance questions

John Reppy <[email protected]> Wed, 15 Aug 2007 22:58:44 -0500
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
On Aug 15, 2007, at 3:17 PM, vaishali chattopadhyay wrote:

> Thank you John for your quick response.
>
> I have few other questions:
>
> - What is the fastest way to apply a function on all
> the elements on a sequence of reals ? Also, what data
> type is most suitable for this kind of operation ?
> vector, array, list? Is it realistic to expect a
> performance close to that of the C language in this
> aspect?

The various combinators, such as app and modify are probably
the fastest way to apply an operation to the elements of an
array.
>
> - What is the difference in terms of internal storage
> for a list,vector and an array of reals i.e are the
> elements stored contiguously in memory?

Vectors and arrays use the same representation, but lists
are linked structures.

>      * Are elements of list, array, vector stored
> internally as their corresponding native C data types
> i.e int, char and double?

The monomorphic array and vector types
have a packed representation, but polymorphic
arrays and vectors (and lists) use uniform
representations for their elements.

>      * What is the performance difference when working
> with long sequences between these data types (i.e.
> vector, array and list)?

It depends on what you are doing.

>      * I have read in the documentation that vector is
> immutable and array is mutable ... other then this
> what other differences exist?

That is the main difference.

>
> - I am also confused about whether smlnj generates
> byte code or native code? It seems like python on the
> other hand generates bytecode, which in turn is
> executed by its interpreter. Is it the same case with
> SML? I have read in some places that SMLNJ produces
> native code and in some places that it is an
> interpreted language. If it produces native code,
> shouldn't its performance be closer to that of C?

SML/NJ generates native machine code.  People are often
confused by the fact that it also supports a read-eval-print
loop, but that is supported using one-the-fly code generation.
There is no bytecode in the SML/NJ implementation.

BTW, if performance is crucial, you might consider developing
your application with SML/NJ (which has a quicker compiler)
and then using the mlton compiler (which does whole program
optimization) for deployment.

	- John


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/