Posts Tagged ‘code’

XNA Efficiency

Sunday, January 25th, 2009

In my brief (somewhat) experience with XNA, I’ve come to realize the XBox isn’t as all powerful as I had once assumed. True, it has a triple-core processor. Yes, it has a decent graphics card. All powerful, hardly, nor should it have to be.

As developers, we should always consider our need for power. A simple game might get away with quick and dirty algorithms. A more complex game, will involve more strategic design methodologies to get the most of out the XBox hardware. Overall, it becomes a bartering system with yourself. Tradeoffs in accuracy to increase performance.

I recently ran into some problems with my team’s upcoming submission to the Imagine Cup.  Luckily the XNA community is vast, so I’ve found out a few simple items: pass matrices by reference whenever possible, and try to avoid using foreach loops for large objects or things that will iterate a large number of times.  Great!  Fine!  What happens when it isn’t enough?  Thats when you have to start diving into the code to find the root of the problem.  Tom Aylesworth wrote a great article about just this.  He said we need to use profiling applications to get a grasp on what is actually (not what we think) is going on with our applications.  Profiling has been an invaluable tool in the XNA development process.

Tom suggests using Nprof since it is free and seems to work well (from the screenshots).  Unfortunately, I can’t get NProf working on my Windows 7 Beta machine.  I know, don’t use a beta for development.  It’s too risky, daring, unstable.  I get it, but I ignore those threats anyway.  Right now I’m running a trial of dotTrace.  Any suggestions on a free Win7/Vista alternative?

All in all, I strongly recommend reading Tom’s series about XNA efficiency especially if you’re new to C#.  It’s a three-parter:
Part1
Part2
Part3