Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
timelimit - limits the amount of CPU time spent on a computation
Calling Sequence
timelimit(t, x)
Parameters
t
-
time limit in seconds
x
expression
Description
The timelimit function evaluates the expression x, but gives up if the evaluation takes longer than the number of seconds specified by t.
Note: For efficiency reasons, the timelimit bound is ignored while in built-in routines.
If the expression is successfully evaluated within the specified time, timelimit returns the value of the expression. If the time limit is reached before the expression is evaluated, timelimit generates the error `time expired`.
The `time expired` error may be caught by a try...catch construct, so long as the try...catch is at a higher level than the call to timelimit. Lower level try...catch constructs (that is, those executed by the expression that is being time-limited) will not catch `time expired`, since to do so would make it impossible to time-limit something which catches exceptions.
The time limit can be specified to the nearest 1/100th of a second, although the actual time allowed can vary by more than that, depending on the underlying architecture, and the Maple operation taking place at the time that the limit expires.
Nested calls to timelimit are allowed, however all time limits are considered to be in effect. Thus an inner call to timelimit will not override the time limit set by an outer call. In addition the `time expired` exception can only be caught outside of the call to timelimit which imposed the limit that expired.
If a nested call to timelimit sets the same limit as an outer call, the outer limit will be treated as the expiring limit.
The timelimit function cannot be used to limit the time of computations within evalhf.
If timelimit is called with a limit of -1, the operation will never time out. Calling timelimit with any other values less than zero will result in an error.
The maximum specifiable time limit is somewhat session dependent, but is usually around 2^24 seconds. To specify a higher time limit value, -1 should be used.
Thread Safety
The timelimit command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Examples
f := proc() global i; for i to 200000 do 2^i end do end proc:
Error, (in f) time expired
See Also
debugger, time, try
Download Help Document