There was a question if SDL is faster or slower on OSX 10.4.
Well - I did a little benchmark based on the tutorial code that comes
with the osx-package (code pasted below).
The programm loads a bmp (128x128, blits it onto the screen (no flip),
counts the blits and displays an average on the console afterwards.
If you’ve got any suggestions how to make this thing faster - please
post them. I only remebered converting the image to the display-format.
Results (SDL 1.2.8):
G5 Dual 2.0, Radeon 9800, OSX 10.3.9:
about 20k blits/s
G4 1.5 (Powerbook), Radeon 9700, OSX 10.4.0:
about 6.5k blits/s
Still pretty slow IMHO. If I remeber correctly, windows came around
with some 100k - would be nice if someone could confirm this, as I
haven’t got any windows- pc around here.
BR Arne
Here’s the code
— 8< —
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL.h>
int main(int argc, char *argv[])
{
int done;
int blits;
int start_time;
int end_time;
int time;
SDL_Event event;
SDL_Surface *screen;
SDL_Surface *sprite;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_ANYFORMAT) < 0) {
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
if ((screen=SDL_SetVideoMode(800,600, 32, SDL_SWSURFACE |
SDL_ANYFORMAT)) == NULL) {
fprintf(stderr, “Couldn’t set 800x600x32 video mode: %s\n”,
SDL_GetError());
SDL_Quit();
exit(2);
}
sprite = SDL_DisplayFormat(SDL_LoadBMP("test.bmp"));
done=0;
blits=0;
start_time = SDL_GetTicks();
while (!done) {
SDL_BlitSurface(sprite, NULL, screen, NULL);
blits++;
while (SDL_PollEvent(&event))
if (event.type==SDL_KEYDOWN)
done=1;
}
end_time = SDL_GetTicks();
time = end_time - start_time;
printf("SDL did %d blits in %d ms, that's about %0.2f
blits/second.\n", blits, time, blits/(time/1000.0f));
SDL_FreeSurface(sprite);
SDL_Quit();
return(0);
}
— >8 —