Switching to Mac caused 20x slowdown - please help!
- To: mathgroup at smc.vnet.net
- Subject: [mg60275] Switching to Mac caused 20x slowdown - please help!
- From: "flatuniverse" <flatuniverse at gmail.com>
- Date: Fri, 9 Sep 2005 04:07:22 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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}
- Follow-Ups:
- Re: Switching to Mac caused 20x slowdown - please help!
- From: Selwyn Hollis <sh2.7183@earthlink.net>
- Re: Switching to Mac caused 20x slowdown - please help!