prof.cc:
myclasses.h:#include <gptl.h> #include <myclasses.h> int main () { X *x; Y *y; int ret; ret = GPTLinitialize (); ret = GPTLstart ("total"); x = new (X); x->func (1.2); x->func (1); delete (x); y = new (Y); y->func (1.2); y->func (1); delete (y); ret = GPTLstop ("total"); ret = GPTLpr (0); }
class Base { public: Base (); ~Base (); }; Base::Base () { } Base::~Base () { } class X: Base { public: X () { } ~X() { } void func (int x) { } void func (double x) { } }; class Y: Base { public: Y (); ~Y(); void func (int); void func (double); }; Y::Y () { } Y::~Y() { } void Y::func (int x) { } void Y::func (double x) { }
% g++ -finstrument-functions prof.cc -o prof -I${GPTL}/include -L${GPTL}/lib -lgptl -lunwind -rdynamic % ./profOutput file timing.0 looks like this:
Stats for thread 0: Called Recurse Wall max min selfOH parentOH total 1 - 3.46e-04 3.46e-04 3.46e-04 0.000 0.000 _ZN1XC1Ev 1 - 3.00e-05 3.00e-05 3.00e-05 0.000 0.000 * _ZN4BaseC1Ev 2 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1X4funcEd 1 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1X4funcEi 1 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1XD1Ev 1 - 2.50e-05 2.50e-05 2.50e-05 0.000 0.000 * _ZN4BaseD1Ev 2 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1YC1Ev 1 - 1.00e-06 1.00e-06 1.00e-06 0.000 0.000 _ZN1Y4funcEd 1 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1Y4funcEi 1 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 _ZN1YD1Ev 1 - 0.00e+00 0.00e+00 0.00e+00 0.000 0.000 Overhead sum = 9.75e-07 wallclock seconds Total calls = 13 thread 0 long name translations (empty when no auto-instrumentation): Multiple parent info for thread 0: Columns are count and name for the listed child Rows are each parent, with their common child being the last entry, which is indented. Count next to each parent is the number of times it called the child. Count next to child is total number of times it was called by the listed parents. 1 _ZN1XC1Ev 1 _ZN1YC1Ev 2 _ZN4BaseC1Ev 1 _ZN1XD1Ev 1 _ZN1YD1Ev 2 _ZN4BaseD1Ev
Otherwise the output is similar to other examples presented here. Parent/child relationships are preserved via indentation. A "*" in column 1 means means that the region (routine in this case) has multiple parents. The multiple parent information is presented below the main output.