MathGroup Archive 2010

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

Search the Archive

How fast does & perform?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107293] How fast does & perform?
  • From: Canopus56 <canopus56 at yahoo.com>
  • Date: Mon, 8 Feb 2010 03:35:33 -0500 (EST)

Setting aside the syntax question of the thread "What does & mean?", there appears to be a performance difference between the two syntax forms. Looks like the := form is faster: 

data = Table[x, {x, (\[Pi]/8), \[Pi], (\[Pi]/512)}]

g[x_] := x*Sin[x]

Timing[Table[g[data[[k]]], {k, 1, Length[data]}]]

2.71051*10^-17 seconds

Timing[Map[g, data]]

0. seconds

Timing[Map[g[#] &, data]] 

0.016 seconds

Timing[Map[#*Sin[#] &, data]]

0.031 seconds

Timing[#*Sin[#] & /@ data]

0.032 seconds

- Kurt 



  • Prev by Date: Re: Re: Re: What does & mean?
  • Next by Date: Re: Integral confusion
  • Previous by thread: Re: Viviani's Curve
  • Next by thread: Re: How fast does & perform?