|
Contents | Previous | Next | Subchapters |
| Syntax |
profileoption) |
| See Also |
time
|
profile
function is the current profiling information as a character matrix.
Each row of the return value corresponds to a function and contains
three fields separated by commas. The first field
is the total time corresponding to the function in seconds.
The second field is the name of the function.
If the function is local to a file, the third field is the
name of the file. If the function is not local to a file, the third field
is blank. The
align
function can be used to line up the
fields in the return value. The
sort
function can be used to
sort this information.
"on",
profiling is turned on and the total time for each
function is initialized as zero.
"off",
profiling is turned off. This will free the memory that is used
for profiling and it will make function calls and returns slightly faster.
clear
function fac1(n) begin
if n == 1 then return 1d0
return n * fac1(n - 1)
end
function fac2(n) begin
fac = 1d0
for i = 1 to n begin
fac = fac * i
end
return fac
end
profile("on")
fac1(200);
fac2(200);
print profile
O-Matrix will respond
0.140,fac1,
0.010,fac2,
(Note that the times on your system will probably be different.)
This shows that the fac2 function computes
factorials faster than the fac1 function.
If you call the profile function with no arguments
when profiling is turned off, an error message will result.
You cannot call the profile function from within another function.