MathGroup Archive 2012

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

Search the Archive

Re: Could someone help optimize this for Mathematica 9?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128956] Re: Could someone help optimize this for Mathematica 9?
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 5 Dec 2012 03:15:58 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121204091410.B2B8E68C4@smc.vnet.net>

mNumberSamples = 100000;
mFrequency = 10;
m = Table[{t/mNumberSamples,
     Sin[t/mNumberSamples mFrequency*2 \[Pi]]}*1.0,
     {t, 1, mNumberSamples}];

mStartTime = SessionTime[];
ListLinePlot[m]
mStopTime = SessionTime[];
StringForm["Elapsed time = ``", t1 = N[mStopTime - mStartTime]]

StringForm["Elapsed time = ``", 4.99887]

$PerformanceGoal /.
 Options[ListLinePlot, PerformanceGoal]

"Quality"

mStartTime = SessionTime[];
ListLinePlot[m, PerformanceGoal :> "Speed"]
mStopTime = SessionTime[];
StringForm["Elapsed time = ``", t2 = N[mStopTime - mStartTime]]

StringForm["Elapsed time = ``", 4.875941]

t2/t1

0.975409

Not much benefit here; however, unless there is some reason why you
need to look at all of the data, you could look at a sample of the
data.

mStartTime = SessionTime[];
ListLinePlot[m[[1 ;; mNumberSamples ;; 100]], PerformanceGoal :> "Speed"]
mStopTime = SessionTime[];
StringForm["Elapsed time = ``", t3 = N[mStopTime - mStartTime]]

StringForm["Elapsed time = ``", 0.058132]

t3/t1

0.011629

Using this approach there is some risk that you would miss a critical
feature. MaxPlotPoints is probably "smarter" at sampling but provides
much less speed benefit.

mStartTime = SessionTime[];
ListLinePlot[m, PerformanceGoal :> "Speed",
 MaxPlotPoints -> mNumberSamples/100]
mStopTime = SessionTime[];
StringForm["Elapsed time = ``", t4 = N[mStopTime - mStartTime]]

StringForm["Elapsed time = ``", 3.893177]

t4/t1

0.778811


Bob Hanlon


On Tue, Dec 4, 2012 at 4:14 AM, McHale, Paul <Paul.McHale at excelitas.com> wrote:
> We have a strong need to view large numbers of data points.  Mathematica 8 was excellent at this.  The following code executed under both 8 and 9 (Windows):
>
> Mathematica 8: Less than 0.5 seconds
> Mathematica 9: Greater than 4 seconds
>
> mNumberSamples=100000;
> mFrequency=10;
> m=Table[{t/mNumberSamples ,Sin[t/mNumberSamples mFrequency*2 \[Pi]]}*1.0,{t,1,mNumberSamples}];mStartTime=SessionTime[];
> ListLinePlot[m]
> mStopTime=SessionTime[];
> StringForm["Elapsed time = ``", N[mStopTime-mStartTime]]
>
> I have tried the code on a slower mac laptop (version 9 only) and had the same slower results.  Any input welcome as this functionality is extremely important to us.
>
>
> Paul McHale  |  Electrical Engineer, Energetics Systems  |  Excelitas Technologies Corp.
>
>
>
>
>
> Phone:   +1 937.865.3004   |   Fax:  +1 937.865.5170   | Mobile:   +1 937.371.2828
> 1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
> Paul.McHale at Excelitas.com
> www.excelitas.com
>
>
>
>



  • Prev by Date: Re: Integral that should converge, but Mathematica says it does not
  • Next by Date: Modifying Default Stylesheet
  • Previous by thread: Re: Could someone help optimize this for Mathematica 9?
  • Next by thread: Mathematica 9: bug in merging cells