MathGroup Archive 2011

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

Search the Archive

Re: Timing function

  • To: mathgroup at
  • Subject: [mg123002] Re: Timing function
  • From: "Oleksandr Rasputinov" <oleksandr_rasputinov at>
  • Date: Sun, 20 Nov 2011 05:35:57 -0500 (EST)
  • Delivered-to:
  • References: <ja84v7$ifg$>

On Sat, 19 Nov 2011 11:46:47 -0000, Mark <big.dog1 at> wrote:

> Hello community:
> When I run the following expression below, It returns the value of zero  
> for the timing. If I press "shift enter" again, it then correctly  
> returns the amount of time for the expression to run / plot.
> Also, I noticed that if I change the variable from x^3 to x^2 and press  
> "shift enter" at that point, zero again is returned for the timing  
> result. I am using Mathematica 8.01
> Timing[Plot[x^3, {x, -5, 5}]]
> Does anyone know the reason for this?

This observation is probably due to clock granularity. On Windows, for  
example, the system clock has a (default) resolution of 1/64s; each clock  
tick triggers an interrupt and consumes some CPU time so it is not helpful  
to have an extremely high resolution system clock. As a result (again, on  
Windows) the maximum supported resolution is 0.5ms. Since plotting a  
simple function takes only a short time, it is a matter of chance as to  
whether the timing is reported as 0 or 1 clock ticks: this will be  
reported as either 0. or 0.015625 seconds in the output from Timing. Other  
systems use different clock granularities, but in general one should not  
trust timings that are at the limit of the system's ability to measure.  
Instead, either repeat the operation sufficiently many times (e.g. using  
Do) that the total timing is much longer than a single clock tick, or use  
a timing mechanism with higher resolution than the system clock.

  • Prev by Date: Re: Data binning with CUDA
  • Next by Date: Re: Problem displaying user-created .cdf files
  • Previous by thread: Timing function
  • Next by thread: Re: Timing function