MathGroup Archive 2000

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

Search the Archive

Re: Ron Knapp's time function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24612] Re: Ron Knapp's time function
  • From: Robert Knapp <rknapp at wolfram.com>
  • Date: Fri, 28 Jul 2000 17:23:48 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • References: <8kjehf$e6o@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

fkampas wrote:
> 
> Does anybody have the Mathematica code
> for the generalized timing function that Ron
> Knapp presented at the last developer's
> conference?  It isn't given in his notebooks
> in the conference section on the Wolfram
> web site.

I tried posting this before, but it must have been lost:


There is a more complete archive of talk notebooks I have used on my
personal web page:

http://members.wri.com/rknapp/Talks

.... and therein you will find

http://members.wri.com/rknapp/Talks/DeveloperConference99/time.nb

which contains the function you seek.

The time function is also used and included in my most recent
Mathematica Journal article, which you can find pointers to through the
main Wolfram research site www.wolfram.com

-------------

Or simpler yet, here is the code

SetAttributes[time, HoldAll];

time[expr_] := 
  Block[{Second = 1}, Module[{t = First[Timing[expr]], tries = 1},
      While[t < 1., tries *= 2; t = First[Timing[Do[expr, {tries}];]]];
      t/tries
      ]
    ] ]
        

The intent of this function is to allow you to compare timings of
operations which may take only fractions of a second by using repetition
to smooth over the timing granularity.  It also suppresses the command
output which, for people like me who are forgetful, avoids accidental
huge outputs when comparing timings.



  • Prev by Date: Re: Simlifying Sqrt[x^2] type args.
  • Next by Date: interruptedWhile ADDENDUM
  • Previous by thread: Re: Ron Knapp's time function
  • Next by thread: Q: Replacing Symbols