Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Re: Compress timing with different data types

  • To: mathgroup at
  • Subject: [mg97767] Re: Compress timing with different data types
  • From: ragfield <ragfield at>
  • Date: Sat, 21 Mar 2009 05:16:10 -0500 (EST)
  • References: <gpsr4o$mh9$> <gpvh67$gp4$>

On Mar 20, 2:38 am, mark mcclure <mcmcc... at> wrote:
> On Mar 19, 3:10 am, Yves Klett <yves.kl... at> wrote:
> > I noticed that the speed of Compress is very much dependent on
> > the type of data that is compressed:
> > ...
> > compressing an expression only containing lists and numbers is about
> > 60 times faster than compressing an expression containing Line
> > statements. And the difference gets worse the larger the expression
> > becomes...
> > Does anyone have experience and/or a workaround with that
> > behaviour (6.03 & 7.01 on WinXP)?
> Running your code in both V6.0.3 and V7.0.1 on my Mac laptop, I get
> speed ratios of more like 6 or 7, rather than 60.  Of course, I wouldn'=
> expect Compress to accomplish anything with an array of random
> numbers, while an expression containing many copies of a Line
> primitve would be compressed a lot.  Perhaps this has something to
> do with it.

It is also a factor of 6-7 different for me on my Mac desktop.

> Incidentally, there's no reason to map Line onto data.  That is
> Line[data] is perfectly valid and renders faster than Line /@ data.

Good point.

Additionally, out of curiosity, what use do you have for Compress/
Uncompress?  This feature is used by the Mathematica front end when
saving notebook files with containing certain large expressions.  It
looks like file I/O is significantly faster at the expense of not
being hand editable:

In[1]:= data = RandomReal[{-1, 1}, {100000, 10, 2}];

In[2]:= AbsoluteTiming[Put[data, "/tmp/a.nb"]]

Out[2]= {12.171807, Null}

In[3]:= AbsoluteTiming[Get["/tmp/a.nb"];]

Out[3]= {7.528877, Null}

In[4]:= AbsoluteTiming[Put[Compress@data, "/tmp/b.nb"]]

Out[4]= {7.931971, Null}

In[5]:= AbsoluteTiming[Uncompress@Get["/tmp/b.nb"];]

Out[5]= {2.116965, Null}

Of course, neither is as fast as DumpSave.

In[6]:= AbsoluteTiming[DumpSave["/tmp/", data];]

Out[6]= {0.372823, Null}

In[7]:= AbsoluteTiming[Get["/tmp/"]]

Out[7]= {0.046271, Null}


  • Prev by Date: Re: Mathematica Graphics - speed bottleneck
  • Next by Date: R: Re: econometrics with mathematica?
  • Previous by thread: Re: Compress timing with different data types
  • Next by thread: Re: Compress timing with different data types