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  /
TimeConstrained

  • TimeConstrained[ expr , t ] evaluates expr, stopping after t seconds.
  • TimeConstrained[ expr , t , failexpr ] returns failexpr if the time constraint is not met.
  • TimeConstrained generates an interrupt to abort the evaluation of expr if the evaluation is not completed within the specified time.
  • TimeConstrained evaluates failexpr only if the evaluation is aborted.
  • TimeConstrained returns $Aborted if the evaluation is aborted and no failexpr is specified.
  • TimeConstrained is accurate only down to a granularity of at least $TimeUnit seconds.
  • Aborts generated by TimeConstrained are treated just like those generated by Abort, and can thus be overruled by AbortProtect.
  • See the Mathematica book: Section 2.13.3.
  • See also: MemoryConstrained, Timing, $IterationLimit, $RecursionLimit, Pause, Abort, TimeConstraint.

    Further Examples

    TimeConstrained returns $Aborted if it cannot perform this evaluation within seconds.

    In[1]:=

    Out[1]=

    See the Further Examples for Timing.