Jump to content
  • Advertisement
Sign in to follow this  

Holy Compile Times, Batman!

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

So last night I had this sudden urge to see if I could refactor windows.h out of my game editor. After four hours of isolating the handful of typedefs and #defines I actually use in a separate header file and writing minimalist wrappers around CreateEvent, _beginthreadex, and CRITICAL_SECTION, I've got everything working again. Only 15 out of 273 cpp files actually need to include windows.h, and I could strip it out of a few more if I wanted to write wrappers around date/time functions and FindFirst/NextFile. Which I don't. But probably will anyway. Granted, the 5-6 wrapper classes that need to actually talk to DirectX or Win32 still need windows.h. Obviously. I just wanted to see how much of the code could be isolated from Win32. The answer? About 98%, based on line count. Once everything's up and running (and I've fixed the one stupid deadlock bug I introduced), I do a full rebuild to see how much faster it would compile. 190,000 lines of code zip through the compiler in 25 seconds. Four hours earlier, this was taking 135 seconds. Roughly 80% of my compile time was being wasted on windows.h. Wowzers. Mind you, this is hardly a new lesson. One year ago this time, my editor was still sitting on top of MFC. You ever try to implement a timeline control in MFC/Win32? Ri-i-ight. I had my own custom software windowing code to take care of that and other special cases. So I spent several months completely rebuilding the app to use a full windowing system sitting on top of DirectX. Hey, I needed a windowing system for my game, and MFC had long since gone from being convenient to being a hinderance. Before, I had 150,000 lines of MFC-based code that took 5 minutes to build. When I was done, I had 140,000 lines of code that took 90-100 seconds to build. And ran full screen at 1,000+ FPS. (But only when not actually doing anything meaningful, of course.) It's hardly news, but trimming those unneeded #includes out of your source files can make dramatic changes to compile times.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!