profile - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

The profile Function

 Calling Sequence profile(procedure1, procedure2, ...)

Parameters

 procedure1, procedure2, ... - any number of valid Maple procedures that have not already been profiled with profile

Description

 • The procedure profile alters the given procedures to record runtime information on the procedures. If profile is successful, it returns NULL on exit.
 • The profiling information is printed using the showprofile() function as shown in the examples below.  For more options and examples see showprofile. To stop collecting profiling information on a function, use unprofile(). To reset the profiler to begin a new profile use resetprofile().
 • Use of profile() increases memory usage and slows down computations, sometimes dramatically.  In addition, profile may not work properly with procedures that have special evaluation rules.
 • A closely related function, exprofile(), can be used to profile all Maple functions at once.

Examples

 > fib:=proc(n) option remember; if n<2 then n else fib(n-1)+fib(n-2) end if; end proc:
 > $\mathrm{profile}\left(\mathrm{fib}\right)$
 > $\mathrm{fib}\left(5\right)$
 ${5}$ (1)
 > $\mathrm{showprofile}\left(\mathrm{fib}\right)$
 function           depth    calls     time    time%         bytes   bytes% --------------------------------------------------------------------------- fib                    5        9    0.000     0.00          6288   100.00 --------------------------------------------------------------------------- total:                 5        9    0.000     0.00          6288   100.00
 > $\mathrm{unprofile}\left(\mathrm{fib}\right)$
 > $\mathrm{profile}\left(\mathrm{gcd},\mathrm{divide},\mathrm{expand},\mathrm{randpoly}\right)$
 > $g≔\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=2,\mathrm{dense}\right)$
 ${g}{≔}{-}{7}{}{{x}}^{{2}}{+}{22}{}{x}{}{y}{-}{94}{}{{y}}^{{2}}{-}{55}{}{x}{+}{87}{}{y}{-}{56}$ (2)
 > $a≔\mathrm{expand}\left(g\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=2,\mathrm{dense}\right)\right):$
 > $b≔\mathrm{expand}\left(g\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=2,\mathrm{dense}\right)\right):$
 > $\mathrm{gcd}\left(a,b\right)$
 ${7}{}{{x}}^{{2}}{-}{22}{}{x}{}{y}{+}{94}{}{{y}}^{{2}}{+}{55}{}{x}{-}{87}{}{y}{+}{56}$ (3)
 > $\mathrm{showprofile}\left(\right)$
 function           depth    calls     time    time%         bytes   bytes% --------------------------------------------------------------------------- gcd                    1        1    0.006   100.00        533664    85.91 randpoly               1        3    0.000     0.00         80976    13.04 expand                 1        8    0.000     0.00          3488     0.56 divide                 1        6    0.000     0.00          3056     0.49 --------------------------------------------------------------------------- total:                 4       18    0.006   100.00        621184   100.00
 > $\mathrm{resetprofile}\left(\right)$
 > $\mathrm{profile}\left(\mathrm{gcd},\mathrm{divide},\mathrm{content}\right)$
 > $g≔\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=3,\mathrm{dense}\right):$
 > $a≔\mathrm{expand}\left(g\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=7,\mathrm{dense}\right)\right):$
 > $b≔\mathrm{expand}\left(g\mathrm{randpoly}\left(\left[x,y\right],\mathrm{degree}=7,\mathrm{dense}\right)\right):$
 > $\mathrm{gcd}\left(a,b\right)$
 ${92}{}{{x}}^{{3}}{-}{6}{}{{x}}^{{2}}{}{y}{-}{72}{}{x}{}{{y}}^{{2}}{-}{87}{}{{y}}^{{3}}{-}{74}{}{{x}}^{{2}}{-}{37}{}{x}{}{y}{-}{44}{}{{y}}^{{2}}{+}{23}{}{x}{-}{29}{}{y}{-}{98}$ (4)
 > $\mathrm{showprofile}\left(\right)$
 function           depth    calls     time    time%         bytes   bytes% --------------------------------------------------------------------------- gcd                    1        1    0.003   100.00        242960    98.81 divide                 1        6    0.000     0.00          2928     1.19 content                0        0    0.000     0.00             0     0.00 --------------------------------------------------------------------------- total:                 2        7    0.003   100.00        245888   100.00

 See Also