Re: Switching to Mac caused 20x slowdown - please help!

*To*: mathgroup at smc.vnet.net*Subject*: [mg60286] Re: [mg60275] Switching to Mac caused 20x slowdown - please help!*From*: Selwyn Hollis <sh2.7183 at earthlink.net>*Date*: Sat, 10 Sep 2005 06:46:37 -0400 (EDT)*References*: <200509090807.EAA16024@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

That runs in about 0.01 seconds on my Dual 2.5GHz G5, which doesn't make much sense compared to either of your timings. But I have two suggestions: 1) Open your Energy Saver preference pane, click on Options, and set processor performance to Highest. 2) Try using Compile to speed up your code. Regards, Selwyn Hollis http://www.appliedsymbols.com http://www.math.armstrong.edu/faculty/hollis On Sep 9, 2005, at 4:07 AM, flatuniverse wrote: > Hello All, > > I'm having a major speed problem in moving from Linux to Mac. > > Old machine: Dell Inspiron 8100 - 1GHz Pentium 3, 512MB RAM - Linux > RedHat - Mathematica 5 > New Machine: Apple Powerbook - 1.3GHz G4, 512MB RAM - OS 10.4.2 - > Mathematica 5.2 > > The bit of code below, which I need to loop many many times, is now > taking about 20 times longer - from ~.01 sec in Linux to ~.2 sec in > OSX. The lag seems to be in the first function, "newh2" which I admit > is probably implemented very poorly. I tried simpler versions using > "If" and "Piecewise," but that caused the second function > "magFromq" to > fail. Can anyone speed up this code? > > Thank you very much! > > > H0 = 3.335*^-10 ; > > \!\(\(newh2[ > z_?NumberQ, dq_, dz_, z1_, Om_: .28] := Module[{h2temp, qmodify, > z2}, \[IndentingNewLine]z2 = > z1 + dz; h2temp = Om*\((1 + z)\)\^3 + \((1 - Om)\); \ > \[IndentingNewLine]qmodify = \((\(1 + > z\)\/\(1 + z1\))\)\^\(2 dq*\((UnitStep[z - z1] - > UnitStep[z - z2])\)\)\ *\((\(1 + z2\)\/\(1 + > z1\))\)\^\(2 dq*UnitStep[z - > z2]\); \[IndentingNewLine]h2temp *= > qmodify\[IndentingNewLine]];\)\) > > \!\(\(magFromq[z_?NumberQ, dq_: 0, dz_: .01, z1_: > 99, Om_: .28, h_: .717137] := 5 Log[10, \((1 + z)\)\/\(10 > h*H0\)\ NIntegrate[1\/\@newh2[x, dq, dz, z1, Om], {x, 0, > z}]];\)\) > > magFromq[2,.05,.05,1]//Timing > > {0.235472 Second,45.9423} > >

**References**:**Switching to Mac caused 20x slowdown - please help!***From:*"flatuniverse" <flatuniverse@gmail.com>