Message Boards Message Boards


Is this correct Timing behavior ?

Posted 9 years ago
5 Replies
2 Total Likes
I type this
and I get 0. for the time. I tried with all other possible expressions and the same holds. This seems to work in the OS X version we run at work.
5 Replies
The "quantum of time" is typically 16 mSec for Windows, but can change depending on what's loaded.
POSTED BY: Frank Kampas
If the computations takes less that $TimeUnit, it will round to zero. Does this return zero on your system:
POSTED BY: Nasser M. Abbasi
Ok, whatever glitch happened with Timing, it is gone :-/ but I am still unable to use it in my program. See, what I attempt to do:
SetAttributes[MyTime, HoldAll];
MyTime[expression_, prefix_: "expression"] :=
  Block[{text = "Time for " <> prefix <> " is "}, Print["Starting"];
   Block[{aux2 = Timing[Evaluate[expression]]}, Print["Finished"];
    Print[text <> ToString[ aux2[[1]]*1000] <> "ms"]; aux2[[2]]]];
This always prints zero, no matter how long the computation in "expression" takes. Using AbsoluteTiming also does not work.
does not measure wall clock time, it measures CPU time spent in the kernel.  Pause[] does not use much CPU time in the kernel at all (nothing to compute, just makes an OS call), so you get zero CPU time.
which returns
{1.000627, Null}
Which returns wall clock time elapsed:
 returning a list of the absolute number of seconds in real time that have elapsed
POSTED BY: Nasser M. Abbasi
I reckon it was an unfortunate example, but if I replace Pause[1.0] with an actual computation, as in the examples from it also does not work.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract