PDA

View Full Version : Qt + gprof in a multithreaded app?



papercut
21st October 2009, 18:12
Hi all,

I'm running my Qt app with gprof, but I'm not convinced that my result is correct.
Here's the first few lines from my gprof output:


% cumulative self self total
time seconds seconds calls ms/call ms/call name
39.22 1.82 1.82 69 26.38 26.38 FilterTemporal::FilterTemporal(int, int)
38.58 3.61 1.79 144 12.43 12.43 FilterS::freeMemory()
16.38 4.37 0.76 48 15.83 28.26 TwoDSFilterAPI<unsigned short>::two_d_s_filter_put_image()
4.96 4.60 0.23 48 4.79 4.79 ProcessImg::ProcessImg(FilterUnsqrtLn*)

This is a image processing program that loads images from the disk and uses a bunch of spatial and temporal noise reduction algorithms, and I'm not convinced at all that my (one of many) constructor is causing 40% of CPU time, and my free() call (which is basically if !null delete pointer) is taking up the other 40%.

For a sanity check, I put a printf at the first line of my FilterTemporal constructor call and indeed it does not print 69 times, but about 20 times or so. Is this because my program is multithreaded? There are many threads which spawn a FilterTemporal class (in fact I spawn a thread for every frame in an image sequence).

Here's also the code for the constructor attached, to show that it does nothing crazily expensive:


FilterTemporal::FilterTemporal(int nbFIR, int maxVarPixel)
{
printf("in constructor\n");
this->nbFIR = nbFIR;

this->maxVarPixel = maxVarPixel;

multiImgOper = new MultiImgOper<unsigned short int, unsigned short int>();
if(multiImgOper == NULL)
{
printf("Error memory allocation\n");
exit(-1);
}

// set default filter factors
Wn[0] = 1;
Wn[1] = 0;
Wn[2] = 0;
Wn[3] = 0;
Wn[4] = 0;
}