Duff's loop

Just looked at the duff’s loop implementation in the SDL CVS and I
think I may try my hand at optimizing it a little. I just need to
know what would be the best test to see if it my changes are making a
difference. I was going to use testsprite until I saw it used RLE
acceleration. Is it just as simple as blitting a lot of things to the
screen and calculating a frame rate or am I missing something?

Phoenix Kokido
members.xoom.com/kokido
@Wes_Poole

Just looked at the duff’s loop implementation in the SDL CVS and I
think I may try my hand at optimizing it a little. I just need to
know what would be the best test to see if it my changes are making a
difference. I was going to use testsprite until I saw it used RLE
acceleration. Is it just as simple as blitting a lot of things to the
screen and calculating a frame rate or am I missing something?

I was using the attached code.
A better test would perform different sub-image blits testing various
memory alignments, etc.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
-------------- next part --------------

#include <SDL.h>

main(int argc, char *argv[])
{
SDL_Surface *src, *dst;
SDL_Rect area = { 0, 0, 1024, 768 };
int i;
Uint32 then, now, ms;

SDL_Init(0);
if ( argc != 3 ) {
	printf("Usage: %s srcbpp dstbpp\n", argv[0]);
	exit(1);
}
src = SDL_CreateRGBSurface(0, area.w, area.h, atoi(argv[1]), 0,0,0,0);
dst = SDL_CreateRGBSurface(0, area.w, area.h, atoi(argv[2]), 0,0,0,0);
then = SDL_GetTicks();
for ( i=0; i<500; ++i ) {
	SDL_LowerBlit(src, &area, dst, &area);
}
now = SDL_GetTicks();

ms = now-then;
printf("Time: %d ms (%2.2f fps)\n", ms, 500.0/((float)ms/1000.0));

}