7.7 Profiling

Profiling of code can be used to determine in which parts of a program how much time has been spent during runtime.

  • ProfileOperations( [true/false] ) F

    When called with argument true, this function starts profiling of all operations. Old profiling information is cleared. When called with false it stops profiling of all operations. Recorded information is still kept, so you can display it even after turning the profiling off.

    When called without argument, profiling information for all profiled operations is displayed (see DisplayProfile).

  • ProfileOperationsAndMethods( [true/false] ) F

    When called with argument true, this function starts profiling of all operations and their methods. Old profiling information is cleared. When called with false it stops profiling of all operations and their methods. Recorded information is still kept, so you can display it even after turning the profiling off.

    When called without argument, profiling information for all profiled operations and their methods is displayed (see DisplayProfile).

  • ProfileMethods( ops ) F

    starts profiling of the methods for all operations in ops.

  • UnprofileMethods( ops ) F

    stops profiling of the methods for all operations in ops. Recorded information is still kept, so you can display it even after turning the profiling off.

  • ProfileFunctions( funcs ) F

    turns profiling on for all function in funcs. You can use ProfileGlobalFunctions (see ProfileGlobalFunctions) to turn profiling on for all globally declared functions simultaneously.

  • UnprofileFunctions( funcs ) F

    turns profiling off for all function in funcs. Recorded information is still kept, so you can display it even after turning the profiling off.

  • ProfileGlobalFunctions( true ) F
  • ProfileGlobalFunctions( false ) F

    ProfileGlobalFunctions(true) turns on profiling for all functions that have been declared via DeclareGlobalFunction. A function call with the argument false turns it off again.

  • DisplayProfile( ) F
  • DisplayProfile( funcs ) F

    In the first form, DisplayProfile displays the profiling information for profiled operations, methods and functions. If an argument funcs is given, only profiling information for the functions in funcs is given. The information for a profiled function is only displayed if the number of calls to the function or the total time spent in the function exceeds a given threshold (see PROFILETHRESHOLD).

    Profiling information is displayed in a list of lines for all functions (also operations and methods) which are profiled. For each function, ``count'' gives the number of times the function has been called. ``self'' gives the time spent in the function itself, ``child'' the time spent in profiled functions called from within this function. The list is sorted according to the total time spent, that is the sum ``self''+``child''.

  • PROFILETHRESHOLD V

    This variable is a list [cnt ,time ] of length two. DisplayProfile will only display lines for functions which are called at least cnt times or whose total time (``self''+``child'') is at least time. The default value of PROFILETHRESHOLD is [10000,30].

  • ClearProfile( ) F

    clears all stored profiling information.

    gap> ProfileOperationsAndMethods(true);
    gap> ConjugacyClasses(PrimitiveGroup(24,1));;
    gap> ProfileOperationsAndMethods(false);
    gap> DisplayProfile();
      count  self/ms  chld/ms  function                                           
    [the following is excerpted from a much longer list]
       1620      170       90  CycleStructurePerm: default method                 
       1620       20      260  CycleStructurePerm                                 
     114658      280        0  Size: for a list that is a collection              
        287       20      290  Meth(CyclesOp)                                     
        287        0      310  CyclesOp                                           
         26        0      330  Size: for a conjugacy class                        
       2219       50      380  Size                                               
          2        0      670  IsSubset: for two collections (loop over the ele*  
         32        0      670  IsSubset                                           
         48       10      670  IN: for a permutation, and a permutation group     
          2       20      730  Meth(ClosureGroup)                                 
          2        0      750  ClosureGroup                                       
          1        0      780  DerivedSubgroup                                    
          1        0      780  Meth(DerivedSubgroup)                              
          4        0      810  Meth(StabChainMutable)                             
         29        0      810  StabChainOp                                        
          3      700      110  Meth(StabChainOp)                                  
          1        0      820  Meth(IsSimpleGroup)                                
          1        0      820  Meth(IsSimple)                                     
        552       10      830  Meth(StabChainImmutable)                           
         26      490      480  CentralizerOp: perm group,elm                      
         26        0      970  Meth(StabilizerOfExternalSet)                      
        107        0      970  CentralizerOp                                      
        926       10      970  Meth(CentralizerOp)                                
        819     2100     2340  Meth(IN)                                           
          1       10     4890  ConjugacyClasses: by random search                 
          1        0     5720  ConjugacyClasses: perm group                       
          2        0     5740  ConjugacyClasses                                   
                6920           TOTAL                                              
    gap> DisplayProfile(StabChainOp,DerivedSubgroup); # only two functions
      count  self/ms  chld/ms  function                                           
          1        0      780  DerivedSubgroup                                    
         29        0      810  StabChainOp                                        
                6920           OTHER                                              
                6920           TOTAL                                              
    

    Note that profiling (even the command ProfileOperationsAndMethods(true)) can take substantial time and GAP will perform much more slowly when profiling than when not.

  • DisplayCacheStats( ) F

    displays statistics about the different caches used by the method selection.

  • ClearCacheStats( ) F

    clears all statistics about the different caches used by the method selection.

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000