On Wed, Sep 23, 2009 at 03:50:54AM -0300, Paulo Pinheiro wrote: > Hello, > > I`m using agar for a video player application and i notice a high cpu usage... > When using agar i saw the app eating up 90-100% of CPU( tested with top ), > while using pure SDL it was only about 30%. I tried to profile the program > and 30% of time was in Draw routine while the rest was in SDL_PumpEvents, > notice that all the player complexity is in draw routine. Is it normal > behavior or am i doing something wrong?
The stock event loop will use all CPU it needs to achieve your target refresh rate; the default refresh rate is 60fps. If you use SDL mode, you'll probably want a much lower value that so that the event loop gets a chance to idle. See: http://libagar.org/man3/AG_SetRefreshRate Using SDL mode, most of your CPU time is spent filling rectangles and drawing pixels in software. This is why SDL mode is not recommended except on platforms lacking hardware-accelerated graphics. Using OpenGL mode (pass AG_VIDEO_OPENGL or AG_VIDEO_OPENGL_OR_SDL to AG_InitVideo()), all rendering is done efficiently in hardware, with almost no CPU usage involved. It is always preferable for applications to support both modes, OpenGL for performance and falling back to SDL for portability. _______________________________________________ Agar mailing list [email protected] http://libagar.org/lists.html
