Re: Re: Re: How fast does & perform?
- To: mathgroup at smc.vnet.net
- Subject: [mg107353] Re: [mg107321] Re: [mg107307] Re: How fast does & perform?
- From: Canopus56 <canopus56 at yahoo.com>
- Date: Wed, 10 Feb 2010 03:36:18 -0500 (EST)
- References: <hkoic7$t30$1@smc.vnet.net> <201002081255.HAA07568@smc.vnet.net> <201002090744.CAA10572@smc.vnet.net>
cire g wrote:
---- Original Message ----
From: cire g <eric.phys at gmail.com>
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}
where:
g[x_] := x*Sin[x]
- References:
- Re: How fast does & perform?
- From: Szabolcs Horvát <szhorvat@gmail.com>
- Re: Re: How fast does & perform?
- From: cire g <eric.phys@gmail.com>
- Re: How fast does & perform?