MathGroup Archive 2003

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

Search the Archive

Re: Curious Timing Results

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38666] Re: [mg38651] Curious Timing Results
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 4 Jan 2003 07:25:50 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

You can see the difference as follows:

In[17]:=
<<Developer`

In[18]:=
  x = Table[2.,{i,100000}];

In[19]:=
PackedArrayQ[x]

Out[19]=
True

In[20]:=
y = Table[If[i<1000000,2.,i],{i,100000}];

In[21]:=
PackedArrayQ[y]

Out[21]=
False

THe need to unpack a packed array makes the first code run slower.


Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/




On Friday, January 3, 2003, at 02:15 PM, Chris Grant wrote:

>
> I find the Timing results below a little curious.  Is there a simple
> explanation why I shouldn't?
>
> Chris Grant
>
> In[1]:=  x = Table[2.,{i,100000}];
>
> In[2]:=  y = Table[If[i<1000000,2.,i],{i,100000}];
>
> In[3]:=  SameQ[x,y]
>
> Out[3]=  True
>
> In[4]:=  Timing[Inner[Divide,x,x]]
>
> Out[4]=  {0.44 Second,100000.}
>
> In[5]:=  Timing[Inner[Divide,y,y]]
>
> Out[5]=  {0.321 Second,100000.}
>
>
>



  • Prev by Date: OOP experiments- Component
  • Next by Date: Re: Solving Alphametics with Mathematica
  • Previous by thread: Re: Curious Timing Results
  • Next by thread: Re: Curious Timing Results