MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Re: How fast does & perform?

cire g wrote: 
---- Original Message ----
From: cire g <eric.phys at>
Subject: [mg107353] [mg107321] Re: [mg107307] Re: How fast does & perform?
> This is what I get (Linux x86_64, version 7) I have to put [[1]] 
> becaue timing also put the output..

Please note the use of the 10,000,000 element list in order to obtain a valid test via: 

data = RandomReal[{-\[Pi], \[Pi]}, 10000000];

Here are the results for a Windows XP 1.7Ghz box by increasing time of execution.  For most practical problems, the syntax chosen does not appear to be a constraint with the # and highly symbolic form for Map being the fastest. The form Map[g, data] appears to be equally fast (for most practical applications) and also meets a criteria of ease of reading:

In[9]:= Timing[#*Sin[#] & /@ data;]
Out[9]= {3.812, Null}

In[6]:= Timing[Map[g, data];]
Out[6]= {5.422, Null}

In[8]:= Timing[Map[#*Sin[#] &, data];]
Out[8]= {8.188, Null}

In[7]:= Timing[Map[g[#] &, data];]
Out[7]= {13.125, Null}

In[5]:= Timing[Table[g[data[[k]]], {k, 1, Length[data]}];]
Out[5]= {17.656, Null}

g[x_] := x*Sin[x] 

  • Prev by Date: errorbar
  • Next by Date: LogPlot is blank when Exported as pdf
  • Previous by thread: Re: Re: How fast does & perform?
  • Next by thread: Re: How fast does & perform?