# 3.21 Profile

`Profile( true )`

In this form `Profile` turns the profiling on. Subsequent computations will record the time spent by each function and the number of times each function was called. Old profiling information is cleared.

`Profile( false )`

In this form `Profile` turns the profiling off again. Recorded information is still kept, so you can display it even after turning the profiling off.

`Profile()`

In this form `Profile` displays the collected information in the following format.

```    gap> Factors( 10^21+1 );;    # make sure that the library is loaded
gap> Profile( true );
gap> Factors( 10^42+1 );
[ 29, 101, 281, 9901, 226549, 121499449, 4458192223320340849 ]
gap> Profile( false );
gap> Profile();
count    time percent time/call child function
4    1811      76     452    2324  FactorsRho
18     171       7       9     237  PowerModInt
127      94       3       0      94  GcdInt
41      83       3       2     415  IsPrimeInt
91      59       2       0      59  TraceModQF
511      47       1       0      39  QuoInt
22      23       0       1      23  Jacobi
116      20       0       0      31  log
3      20       0       6      70  SmallestRootInt
1      19       0      19    2370  FactorsInt
26      15       0       0      39  LogInt
4       4       0       1       4  Concatenation
5       4       0       0      20  RootInt
7       0       0       0       0  Add
26       0       0       0       0  Length
13       0       0       0       0  NextPrimeInt
4       0       0       0       0  AddSet
4       0       0       0       0  IsList
4       0       0       0       0  Sort
8       0       0       0       0  Append
2369     100                  TOTAL ```

The last column contains the name of the function. The first column contains the number of times each function was called. The second column contains the time spent in this function. The third column contains the percentage of the total time spent in this function. The fourth column contains the time per call, i.e., the quotient of the second by the first number. The fifth column contains the time spent in this function and all other functions called, directly or indirectly, by this function.

GAP 3.4.4
April 1997