Hi!
I have noticed that using SDL_PollEvent() with SDL_Delay() uses much
more processor time than expected. The program below leaves my
Celeron 1700 on 60% idle. I have a similar program using
PeekMessage() and Sleep() from MS Windows API, and then my processor
is 95% idle.
Does anyone know why is this so?
I use MS VC 6.0 (“Release” settings), SDL 1.2.6.=========================================================
#include <sdl/sdl.h>
int main(int argc,char**argv)
{
SDL_Surface *screen;
SDL_Event event;
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) return 0;
screen = SDL_SetVideoMode(1024, 768, 8, SDL_HWPALETTE |
SDL_FULLSCREEN );
if ( screen == NULL ) return 0;
while(1){
if (SDL_PollEvent(&event)==0){
SDL_Delay(1);
}
SDL_Delay(1);
}
}
Kresimir Cosic wrote:
I have noticed that using SDL_PollEvent() with SDL_Delay() uses much
more processor time than expected. The program below leaves my Celeron
1700 on 60% idle. I have a similar program using PeekMessage() and
Sleep() from MS Windows API, and then my processor is 95% idle.
Does anyone know why is this so?
your code on my Athlon 1600+ make 0% cpu use … 99% idle …
Kresimir Cosic wrote:
I have noticed that using SDL_PollEvent() with SDL_Delay() uses much
more processor time than expected. The program below leaves my
Celeron 1700 on 60% idle. I have a similar program using
PeekMessage() and Sleep() from MS Windows API, and then my processor
is 95% idle.
Does anyone know why is this so?
i’m not sure, but i think you are are running your test programm as
root. AFAIK, SDL_Delay is implemented using usleep() on linux which does
polling for very short delays, when called by root.
hope that helps …
clemens
Hi!
I have noticed that using SDL_PollEvent() with SDL_Delay() uses much
more processor time than expected. The program below leaves my
Celeron 1700 on 60% idle. I have a similar program using
PeekMessage() and Sleep() from MS Windows API, and then my processor
is 95% idle.
Does anyone know why is this so?
I use MS VC 6.0 (“Release” settings), SDL 1.2.6.=========================================================
#include <sdl/sdl.h>
int main(int argc,char**argv)
{
SDL_Surface *screen;
SDL_Event event;
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) return 0;
screen = SDL_SetVideoMode(1024, 768, 8, SDL_HWPALETTE |
SDL_FULLSCREEN );
if ( screen == NULL ) return 0;
while(1){
if (SDL_PollEvent(&event)==0){
SDL_Delay(1);
}
SDL_Delay(1);
}
}
At a higher view…
Maybe that’s because SDL is multiplatform and MS Windows API no…> ----- Original Message -----
From: dont_send_here@boring.com (Kresimir Cosic)
To:
Sent: Friday, October 10, 2003 4:46 PM
Subject: [SDL] SDL_PollEvent uses too much processor time?
Hi!
I have noticed that using SDL_PollEvent() with SDL_Delay() uses much
more processor time than expected. The program below leaves my
Celeron 1700 on 60% idle. I have a similar program using
PeekMessage() and Sleep() from MS Windows API, and then my processor
is 95% idle.
Does anyone know why is this so?
I use MS VC 6.0 (“Release” settings), SDL 1.2.6.
#include <sdl/sdl.h>
int main(int argc,char**argv)
{
SDL_Surface *screen;
SDL_Event event;
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) return 0;
screen = SDL_SetVideoMode(1024, 768, 8, SDL_HWPALETTE |
SDL_FULLSCREEN );
if ( screen == NULL ) return 0;
while(1){
if (SDL_PollEvent(&event)==0){
SDL_Delay(1);
}
SDL_Delay(1);
}
}
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl