Skip to main content
GameDev.net gamedev.net
🔒 Locked

Performance Question

Started by fathom88 Mar 20, 2006 at 6:09 AM 8 replies 750+ views
Original Post
fathom88
fathom88
I've been working to improve the performance of my app. I do real time image processing. I managed to get my filter down to an acceptable level. However, I still need to apply an "amorphic" open and close routine to my pixel data set. I have not finished writing this routine. To test out future loads, I simply called my filter routine twice in place of the unfinished routine. I noticed my performance dropped by a factor of seven. At worst, I would have expected my performance to drop by a factor of two (I'm simply calling the same routine twice). I've come across this problem in the past. Is this simply too much for my cache? Is there anything I can do about it? Currently, I call both routines inside the same thread. Would separating the two buy me anything? Thanks for any help. Pentium M VC++ OpenGL WinXP
Spoonbender
Spoonbender
Maybe I'm just slow, but could you provide a few more details? What does the routine do, how do tou measure performance, and so on. And where do you call it from? And so on... :P
Greig Hamilton
Greig Hamilton
Have you done any profiling of the code to see where the slow down occurs?
Are you sure the test is accurate? How are you doing the test?
The more details you can provide the more help you are likely to get.
fathom88
fathom88
My mistake.

I have a dedicated thread to load my pixel data into a data object. I get my raw data from a socket port. I get a new full screen of pixel data at regular timed intervals.

I have a another thread to process the data and plot the data to the back buffer.

DrawingThread()
{

while(running == true)
{
DataAvail = WaitForSingleObject(DataMutex, WAIT_TIME);

switch(DataAvail)
{
case WAIT_OBJECT_0:

for(int ii = 0; ii < MAX_ROWS_PIXELS; +ii)
{
Filter->SmoothRow(ii); //check neighbor of each pixel in row to smooth
Filter->SmoothRow(ii); //called 2nd to sim load

}

DrawToScreen();
ReleaseMutex(DataMutex);
break;

default:
break;

}
}

}

Sorry about the direct texting of code. Currently I'm just watching the CPU load on the task manager. If you know of any good profilers, please recommend. Hope this helps. Thanks.

Spoonbender
Spoonbender
Dont trust the task manager. A simple way to get better information could be to just insert a few calls to a timer and then print the time spent. That'd be a lot more accurate.

Oh, and use the [ source ] tags for pasting code. [wink]

I can't think of any reason why it'd slow down by more than a factor two though.
Greig Hamilton
Greig Hamilton
Well a simple way is just to time the length spent in each function and the number of times each function is called.

Oh and for profilers, well the following link has some links to some code that you can insert into your project.
http://www.google.se/search?hl=en&q=profiling+code+c%2B%2B

Hopefully this will give you a bit of insight into what is taking up the time. If not at least you will have a tool to use once you want to speed up your code.

Greig

fathom88
fathom88
I did some timer tests, and I found the extra filter call did not increase the time to draw to screen by much. However, the task manager shows an activity level of 50% with the 2nd filter call. When only one filter call is made, the task manager gives a CPU util of 5%. What is the task manager really reporting? Thanks for the previous replies.
lack o comments
lack o comments
Windows is a pre-emptive multitasking system. Many people confuse the task manager for a tool reporting the percentage of the processor being used. The truth being that the processor is always 100% busy. It's really reporting how large of a time slice in the kernel is being devoted to an application. It scales based on all other aplications running. That is to say if one process is using 100% and another starts up with an equal time-slice, they will both then report 50%.

At least, that's what I can tell from conjecture.
ZQJ
ZQJ
I would have thought a usage of 100% meant one application was using all the CPU cycles, and two apps using 50% each means each one only does half as much processing. However I wouldn't trust it as a timing device either because it's sampled at intervals of 1 second or something and the result you get will depend on how the sampling is done and where the sample boundaries fall, the second of which is random chance and the first is probably not known to anyone outside MS.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.