Robot Foot Games Helping you improve your games as we improve our own. :)

20Jul/110

Where Is My XNA Game Running Slow?

Since I do most of my testing on PC (for convenience) and test less often than I should on the 360 there's been time where it'll run smoothly on PC but when I switch over to the 360 it runs pretty choppy. For me, since I never took the time to really learn how to use a profiler, it usually involved me commenting out chunks of my code until it ran smoothly. Although this was effecting it was more time consuming than necessary.

When you first start out you don't really know what is REALLY bad to do. Drawing text to the screen can slow down your game? NO WAY! It seems doing things like 'myInteger.ToString()' many times isn't very good, especially every frame. It's little gotchas like this, that I would've never guessed could be the cause of the slowdown, that made it even more time consuming because it was one of the last things I would check.

Now there's a pretty awesome game component that you can literally just drop into your game and see exactly how fast, or slow, each part of your code is running! It's called the Indiefreaks Game Profiler and you can find it at indiefreaks.com.
Photobucket

Here you can see that about 75% of my time is spend drawing things to the screen. This screenshot is basically only rendering particles though so that's expected. But you can expand the call stack by using the arrow keys (on Windows)  to narrow it down as far as you want. If I want, I can see how long it takes to call my DrawTowerHud() method on a single tower.

Photobucket

We can see that drawing the HUD of one of my towers only accounts for 0.2% of the time drawing objects so that isn't a problem. Being able to navigate through everything in real time makes it very easy to see when/where your slowdowns might be occurring.

The installer comes with directions on how to get it up and running for your game so I won't go through the details of that here, but it's pretty cool to just look around and see exactly where your game is taking the longest to update/render, even if you're not currently having slowdown problems. You can find the download link at their blog post here. You can also report any bugs/feature requests over at their forums.

 

 

Filed under: XNA Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.