Download Maple Introductory Programming Guide

Transcript
334
•
Chapter 8: Debugging and Efficiency
function
depth
calls
time
time%
bytes
bytes%
-------------------------------------------------------------fib2
10
177
0.040
80.00
95300
88.61
fib1
10
19
0.010
20.00
12244
11.39
-------------------------------------------------------------total:
20
196
0.050
100.00
107544
100.00
By studying the run-time information, particularly the number of calls
to each procedure, you can see that it is more efficient to use option
remember in a recursive procedure.
To turn off profiling, use the unprofile command. If no argument is
supplied to unprofile, all procedures currently profiled are returned to
their original state.
unprofile( procedureName );
When a procedure is unprofiled, all run-time information for that
procedure is lost.
> unprofile();
> showprofile();
function
depth
calls
time
time%
bytes
bytes%
--------------------------------------------------------------------------------------------------------------------------total:
0
0
0.000
0.00
0
0.00
8.5
Managing Resources
Maple provides a number of commands to use for managing the computer’s resources during computation. In particular, timelimit controls
the maximum amount of time available for a computation, gc causes
garbage collection, and kernelopts provides communication with the
Maple kernel.
Setting a Time Limit on Computations
The timelimit command is used to limit the amount of CPU time for a
computation. The timelimit command has the following syntax, where
time is the time limit (in seconds) to evaluate expression.