This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Time and Date  /

  • Timing[ expr ] evaluates expr, and returns a list of time used, together with the result obtained.
  • Timing gives the CPU time in seconds, multiplied by the symbol Second.
  • Timing has attribute HoldAll.
  • Timing[ expr ;] will give timing , Null .
  • First[Timing[ expr ;]] /. Second->1 yields just the number of seconds required for the evaluation of expr.
  • Timing is accurate only down to a granularity of at least $TimeUnit seconds.
  • Timing includes only CPU time spent in the Mathematica kernel. It does not include time spent in external processes connected via MathLink or otherwise. Nor does it include time spent in the Mathematica front end.
  • Timing[ expr ] includes only time spent in the evaluation of expr, and not, for example, in the formatting or printing of the result.
  • Timing should give accurate results on all operating systems where the running of processes is specifically scheduled by the operating system.
  • On early versions of Microsoft Windows and MacOS where Mathematica must explicitly yield in order for other processes to run, Timing may substantially overestimate the time used within Mathematica.
  • See the Mathematica book: Section 2.13.3.
  • See also: TimeUsed, TimeConstrained, SessionTime, AbsoluteTime.

    Further Examples

    Here is the CPU time needed to compute a large Bernoulli number. Suppressing the display of the calculation with a semicolon makes a Null appear in its place in the output.



    Doing the computation again is considerably faster because tables were constructed the first time around.