Click here to Skip to main content
Click here to Skip to main content

Reducing game start up time

By , 25 Oct 2010
 

A lot of game developers consider the start-up time of a game to be of little importance. Unfortunately, the truth is that users do not like looking at the hourglass. So, here are two tips to reduce start-up time.

1. Use Targa instead of PNG

PNGs take several times longer to decode than compressed Targa. I think it’s around 5 times slower. (I once made some measurements on the iPhone, but I lost the figures <duh>). On the other hand, compressed Targa files are about 40% bigger, but disk space usually isn't that critical. You can use the code here to decode targa files: http://dmr.ath.cx/gfx/targa/.

An interesting side effect of this optimization is that it also reduces development time. Everytime you start up the debugger, it has to decode all those 1024×1024 textures, before you can begin.

2. Read Files by Blocks, Not Word by Word

Preferably, read the whole file in one go. This is how you do it with C code:

FILE* pFile;
pFile = fopen(fileName.c_str(), "rb");
if (pFile == NULL) return;
fseek(pFile, 0, 2 /* SEEK_END */);
fileSize = (int)ftell(pFile);
fseek(pFile, 0, 0 /* SEEK_SET */);
pBuffer = new char[filesize];
int bytesRead = (int)fread(pBuffer, fileSize, 1, pFile);
fclose(pFile);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ed welch
Software Developer Astronautz
Spain Spain
Member
After working in the software industry for many years, I've started my own games company that specialises in strategy games for mobile platforms.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 3memberJeff R.30 Dec '10 - 5:28 
good tips but expected something more substantial than 2
GeneralCommentsmemberadyinvienna@hotmail.com2 Nov '10 - 22:28 
I've done some work on load times on a PS2 game.
 
Point 2 was key to improved load times for us. We had a large number of .txt script files, image files, config files etc loaded one at a time. I took the solution to the extreme! What I did was make an memory image after loading. Save that, and then for future loading, load that memory image as a single file directly into memory... So getting around open load times, decompression time, memory allocation and pretty much everything that takes time. For release this made over a factor of 3 speed up, though mostly useless during developement as any data change meant you had to make a new memory image file.
 
Point 1, if you have load thread, then image decompression can be done at the same time as loading other data, so its better to have higher compression for faster loading.
GeneralRe: Commentsmembered welch3 Nov '10 - 4:15 
adyinvienna@hotmail.com wrote:
Point 1, if you have load thread, then image decompression can be done at the same time as loading other data, so its better to have higher compression for faster loading.

 
That's an interesting idea. You could be decoding one file while reading from disk from the other one. The effectiveness probably depends on the device. Reading from flash memory probably is a lot faster than reading from a disk drive.
GeneralRe: Commentsmemberadyinvienna@hotmail.com3 Nov '10 - 6:11 
If you've got a big enough read buffer you can load multiple image files in one thread and decompress them continually in another thread, even while your non-image data is loading.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 25 Oct 2010
Article Copyright 2010 by ed welch
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid