The exprofile and excallgraph Statements - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Procedures and Functions : Time and Space : exprofile

The exprofile and excallgraph Statements

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

exprofile(filename, sortflag)

excallgraph(filename, sortflag)

Parameters

filename

-

any valid filename, besides `default`. If `default` is given, Maple reads the input from the standard input. This is useful for piping output from one maple session to another running exprofile or excallgraph.

Description

• 

The exprofile and excallgraph functions are used to display profile information for Maple procedures and libraries.

• 

The filename can be any valid maple output that was generated with kernelopts(profile=true) set.  The preferred method for creating the output file is with writeto() and/or appendto(). If `default` is given for the filename, then input is read from the standard input instead.  This is useful with certain operating systems that support piping.

• 

Depending on the function being profiled, the generated file can become quite large.  Some operating systems support piping and to save disk space one can pipe the standard output of one maple session (generating the profile information with kernelopts(profile=true) to the standard input of a second maple session (running exprofile or callgraph). With UNIX systems, this can be achieved with the following command:

#!/bin/sh

# Unix shell script for generating profile information on functions

( echo "interface(quiet=true); exprofile(default);"

  echo "kernelopts(profile=true); read myfunct; myfunct(100);" | maple

) | maple;

  

Not all operating systems support pipes.

• 

A command line utility is provided for all platforms for processing of large profile files. See nprofile for more information.

• 

The function exprofile creates a table of information which displays how much time a procedure took to execute, how much memory space it used, and how many times the procedure was called.

• 

The procedure excallgraph is a complement of exprofile. excallgraph displays which calls each procedure made, how many times the procedure made the call, how long each call took to execute, and how much memory was used for each call.

• 

The optional argument, sortflag, may be one of the following:

alpha

-  sort table alphabetically by name of function

ralpha

-  sort table reverse alphabetically by name of function

time

-  sort table by increasing usage of cpu time

rtime

-  sort table by decreasing usage of cpu time

words

-  sort table by increasing usage of memory

rwords

-  sort table by decreasing usage of memory

calls

-  sort table by increasing number of calls to each function

rcalls

-  sort table by decreasing number of calls to each function

load

-  sort table by increasing memory^2*time

rload

-  sort table by decreasing memory^2*time

• 

If the optional argument, sortflag, is not specified, the default is rload.

• 

exprofile can interpret its own output and excallgraph's output as well. The advantage of this is that when dealing with limited diskspace, you can concatenate exprofile's output with a second run to get the total runtime information for the two sessions in one table--without having to concatenate two large session files and then run exprofile on the result.

• 

excallgraph can use its output for input as well.  However, excallgraph cannot use exprofile's output as input.

Examples

a:=proc(); b(100); end proc:

b:=proc(n);
  if n>0 then c(n-2); end if;
end proc:

c:=proc(n);
  if n>0 then b(n+1); end if;
end proc:

kerneloptsprofile=true:

writeto'output'

a

kerneloptsprofile=false

writetoterminal

exprofile'output',α

 4 different functions, using 1.210 secs and 750K words

 name                      #calls         cpu                words

 ====                      ======         ===                =====

 Main_Routine                   1       1.110 ( 91.7%)      728757 ( 97.2%)

 a                              1       0.000 (  0.0%)         107 (   .0%)

 b                             99       0.050 (  4.1%)       10648 (  1.4%)

 c                             99       0.050 (  4.1%)       10404 (  1.4%)

excallgraph'output'

                                                         used by callee

    Caller                       Callee              #calls    time    words

    ======                       ======              ======    ====    =====

 ++ <start>                calls Main_Routine            1,   1.210,  749916

 ++ Main_Routine           calls a                       1,    .100,   21159

 ++ a                      calls b                       1,    .100,   21052

 ++ b                      calls c                      99,    .100,   20894

 ++ c                      calls b                      98,    .100,   20809

See Also

appendto

kernelopts

nprofile

profile

writeto

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam