Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

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

Search the Archive

M9 performance regression for Fold?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132264] M9 performance regression for Fold?
  • From: Yi Wang <tririverwangyi at gmail.com>
  • Date: Tue, 28 Jan 2014 06:13:02 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Hello,

I noticed an over 10x performance drop on Mathematica v9.0.1 compared with v7.01 for this code:

SetSystemOptions["CatchMachineUnderflow" -> False];
AbsoluteTiming@
 Fold[{(#[[1]] Sin[10.5])/(#2 + 1), #[[2]] + Tan[#[[1]]]} &, {Sin[
    10.5], 1.0}, N@Range[10^6]]

I got {0.184287, {0., 0.105747}} on v7, but got {2.311755, {0., 0.105747}} on v9. Note that the Do[...] version of above code needs about 2 seconds. Thus I suspect that on v9 the Fold code is not properly auto-compiled.

Is this a regression? (Also is there a way to see if auto-compile worked or not?)

Thanks!
Yi

PS: To compare, I also tried the following code, where the performance on v7 and v9 are roughly the same (v9 is on average 5% more slowly though).

AbsoluteTiming@Fold[# + Sin[#2] &, 1.0, Range[10^6]]

A difference is that here the first argument of function in Fold is a number, and in the problematic example, the first argument is a list.

PS: I noticed this issuee during a discussion at http://mathematica.stackexchange.com/questions/41103/about-auto-compiling-and-performance-between-do-and-fold



  • Prev by Date: How Can I Change the Appearance of a Locator in Manipulate
  • Next by Date: Re: Pure functions vs rule based functions inside NIntegrate
  • Previous by thread: Re: How Can I Change the Appearance of a Locator in Manipulate
  • Next by thread: Re: ???