Re: Cost of Composition vs Pure Function
- To: mathgroup at smc.vnet.net
- Subject: [mg93667] Re: Cost of Composition vs Pure Function
- From: m.r at inbox.ru
- Date: Fri, 21 Nov 2008 05:32:45 -0500 (EST)
- References: <gg3c7c$k3e$1@smc.vnet.net>
Raffy wrote: > The speed difference between these two evaluations seems odd, > considering they are effectively the same thing: > > m = RandomReal[{0, 1}, {10, 1000, 1000}]; > > Total[Total[#]]& /@ m; // Timing => 0.14 sec > > Composition[Total, Total] /@ m; // Timing => 0.983 sec > > Other than the Identity and Inverse Function transformation, where is > this overhead coming from? > > Thanks. The unpacking behaviour is different. In 7.0: In[1]:= On["Packing"] m = RandomReal[{}, {10, 1000, 1000}]; Timing[Total[m, {2, 3}];] Out[3]= {0.031, Null} Maxim Rytin m.r at inbox.ru