MathGroup Archive 2008

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

Search the Archive

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


  • Prev by Date: Re: Mathematica 7 is now available
  • Next by Date: Re: Cost of Composition vs Pure Function
  • Previous by thread: Re: Cost of Composition vs Pure Function
  • Next by thread: Re: Cost of Composition vs Pure Function