Public Group

# finding performance problems

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi Problem: it's slow! :) hehe - so now . . . what's the best way to go to find out where the problem lies? Is it the fillrate? is it the cpu? is it the vertexshader or pixelshader pipelines on the card? There are so many parts involved and i think it's quite possible that often all of them could handle more but have to wait on one single part which can't do it's job that fast as the other parts do theyr job . . . So how to find the weakest link in the chain? I hope you understand :) Thanks for the help!

##### Share on other sites
Try to use a profiler. It will tell you how much time each function consumes and how often it has been called.
If you don't know how to get or use a profiler, try to build some simple kind of profiling yourself, something like this:

startTime = Clock.getCurrentTime();..call your render engine..endTime = Clock.getCurrentTime();renderTime += endTime - startTime;renderCall += 1;... do the same thing for input/ai/gamelogic/gui/phyisc.....

At the end of your program log the profiled informations:
- totalTime = programEndTime - programStartTime
- renderTimeInPercent = 100 * renderTime / totalTime
- renderCall (see above)
- averageRenderCallTime = renderTime / renderCall
- ... same for physics/ai/gamelogic....

You can identify performance bottlenecks by:
1. too many calls of a certain function relative to number of total frames
(i.e. if you got 1000 frames while running your program and there are also 1000 calls of your loadTexture function...)
2. if a certain function consumes too much total time, this function could be your bottleneck.
(i.e. updatePhysics used up 96% of the total running time...)

Some tips and pitfalls:
1. If you identify a complex function as your bottleneck, try to break the profiling down to certain parts of this complex function.
2. Don't try to profile small functions which will be called very often, like a dotProduct function, which will be called 1000 of times per frame. In this case hand written profiling often distorts the profiling result.
3. Calling a render api like OpenGL/DirectX is very fast, because this calls are only queued but not immediately executed. This calls will be executed later. You can force the execution of this render calls with API commands like 'glFinish'(OpenGL). Use this API commands to ensure a better measuring of your rendering time.
I.e. if glFinish used up most of the time, the application is most probably GPU bound. In this case try to change the order of your game-pipeline. Instead of using "userInput=>ai=>physics=>render=>swapBuffer" do something like "render=>userInput=>ai=>physics=>swapBuffer". This setup will ensure that your CPU and GPU works concurrently.

--
Ashaman

1. 1
2. 2
Rutin
20
3. 3
A4L
15
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633739
• Total Posts
3013618
×