Doing stuff is always more expensive than doing nothing

Originally posted to Shawn Hargreaves Blog on MSDN, Wednesday, October 6, 2010

I sometimes get performance questions that go something like "I want to frobnicate my kaboodle, and am considering doing this by flibitzing the wazoo, but I'm worried this might be too expensive".

The only way I know to answer such a question is, mu.

The problem is the phrase "too expensive". It is impossible to judge this without knowing what your limit is, ie. how rich you are. Any time you make a program do more work, that will cost time and usually also memory, but it would be silly to conclude we should do nothing at all! A game that does nothing may run infinitely fast, but it will not be very interesting to play.

Food costs money, but we must eat to survive. Sometimes I eat cheap food; other times I spend more to buy something more delicious. I recently ate at the Herbfarm for my wife Tracy's birthday. That was NOT cheap, certainly not something I could afford to do every day, and I will probably never go back, but it was a fantastic and memorable experience, totally worth it to celebrate a special occasion with special company.

Games are kinda like birthdays: good ones aim to be fantastic, memorable, special, exciting. That's hard to achieve if you're overly focused on saving a few bucks by getting takeout.

With game performance, unlike real life, there is no point trying to save wealth for a rainy day. When your goal is to run at a silky smooth 30 or 60 fps, that means you have either 33 or 16 milliseconds to complete each Update and Draw cycle. If you take longer you get a framerate glitch, but any time you take less, you just wasted some oomph that could have gone into making your game more exciting. It's not like you can save up leftover CPU cycles by spending just 5 milliseconds per tick, then cash in your 401k and spend it all at once when you hit retirement!

Note: the above is only true if you ignore battery life, which can be a reason for phone games to deliberately leave some processing time unused.

When trying to decide if you can afford to flibitz the wazoo, I would start by asking:

Given a fixed amount of CPU cycles, the trick is not to avoid spending them, but to make sure you spend them wisely on things that will provide maximum bang for buck. Get this right, and gamers will be amazed by the stupendous awesomeness that ensues. Get it wrong, and they will think "meh, boring". This is more of an art than a science, but game developers must develop good instincts about which things are worth investing in.

Blog index   -   Back to my homepage