StarCraft Power Saver

What you should know about StarCraft Power Saver:
  size (bytes) MD5 checksum
starcraft_power_saver.exe 12288 de80c2474e7a7397895c5857da14539f
starcraft_power_saver-0.1.zip 28644 e7088c3f16b43f14cf345b23c96df12e

Contact information

To contact the creator and maintainer of StarCraft Power Saver, please use the contact form. If you'd like to make your query public, you can add a comment to the blog post for this tool.

Performance results

StarCraft Power Saver reduces StarCraft's CPU usage from 100% to the following percentages: Feel free to submit your own performance results using the contact information above.

Problem summary

StarCraft uses a game loop to handle all in-game processes, including re-drawing the screen, computing the AI, and handling network traffic. This is a fairly common technique among games of its era. Unfortunately, this technique causes the game to use all the CPU time available to it since StarCraft's creators chose not to limit the frame rate, instead opting to let StarCraft update the display as fast as it can.

While this works fine when you don't care how much CPU power you're wasting, it does not work so well when you're running a laptop on batteries or you want to share your CPU with other applications while playing StarCraft. Furthermore, the frame rate afforded by modern hardware is so insanely high that it makes no sense whatsoever to draw as many frames as the processor can. As an example, on my 1.3 GHz Pentium M, StarCraft draws about 100,000 frames per second.

The solution is to insert a Sleep into the game loop, which causes StarCraft to relinquish the CPU for a set period of time before it starts drawing frames again. For StarCraft Power Saver, I chose to use 1ms as the time to sleep between drawing frames. Because of the low granularity of timers in Windows XP and 2000, the sleep is effectively 10-15ms, but this has proved to be short enough to keep StarCraft responsive, even on a large map with 8 players.

I may post additional information on how to find the game loop and how to determine the speed at which StarCraft executes the loop if there is interest. Feel free to ask any questions you may have about any of this through the contact information listed above.

Valid XHTML 1.0 Transitional