Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6522 > unrolled thread
| Started by | Mark <big.dog1@att.net> |
|---|---|
| First post | 2011-11-19 11:46 +0000 |
| Last post | 2011-11-21 09:38 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Timing function Mark <big.dog1@att.net> - 2011-11-19 11:46 +0000
Re: Timing function "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-20 10:39 +0000
Re: Timing function David Bailey <dave@removedbailey.co.uk> - 2011-11-21 09:38 +0000
| From | Mark <big.dog1@att.net> |
|---|---|
| Date | 2011-11-19 11:46 +0000 |
| Subject | Timing function |
| Message-ID | <ja84v7$ifg$1@smc.vnet.net> |
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?
[toc] | [next] | [standalone]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-11-20 10:39 +0000 |
| Message-ID | <jaald1$17h$1@smc.vnet.net> |
| In reply to | #6522 |
On Sat, 19 Nov 2011 11:46:47 -0000, Mark <big.dog1@att.net> 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.
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2011-11-21 09:38 +0000 |
| Message-ID | <jad65o$ek8$1@smc.vnet.net> |
| In reply to | #6522 |
On 19/11/2011 11:46, Mark 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?
>
The clock granularity has already been mentioned, but I suspect perhaps
that if you are timing Plot commands, you are struggling with more
complex plots that are irritatingly slow! A complication is that Timing
only measures the time used by the kernel, and for some plots, most of
the time is consumed in the frontend. Even AbsoluteTime does not solve
this problem easily, because it returns its result before the FE starts
its work.
I gave a talk at the 2010 autumn conference in Champaign discussing a
variety of subtle timing issues including this problem. You will find a
link to this presentation here:
http://www.wolfram.com/events/techconf2010/speakers.html
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web