MathGroup Archive 2010

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

Search the Archive

Re: How fast does & perform?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg107334] Re: How fast does & perform?
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Tue, 9 Feb 2010 02:47:19 -0500 (EST)
  • References: <hkoic7$t30$1@smc.vnet.net>

Canopus56 wrote:
> 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:

<snip>

Probably not much difference. Timing Mathematica is tricky, since you
don't know if it is caching results.  Since the timing you collected
is down near "1 clock tick" or .016 sec, it is not easily reproduced.
Do 10X as much and you see these are all about the same.

Also passing in to Map    h[#]&   is the same as passing h; it may be
very slightly slower, but not much.
and writing  ../@   is the same as Map except for the parser, so that
doesn't affect runtime.
> 
> 

(Clear[g, h, data];
  data = Table[x, {x, Pi/8, Pi, Pi/5120}];
  g[x_] := x*Sin[x];
  h = #*Sin[#] &;
  Print[Timing[Map[g, data];]];
  Print[Timing[Map[h, data];]];
  Print[Timing[Map[g, data];]];
  Print[Timing[Map[h, data];]];

  )


  • Prev by Date: Re: Test function argument with VectorQ and NumericQ
  • Next by Date: Re: Test function argument with VectorQ and NumericQ
  • Previous by thread: Re: Re: Re: How fast does & perform?
  • Next by thread: Re: How fast does & perform?