Are SDL events slow?

Posts: 1,487
Joined: 2002.09
Post: #1
I just added events to my game development environment that I am making. It's based around SDL and Ruby. After playing with some events code, I noticed that the CPU usage for the program increased by 3% (total). I thought this was a bit odd, I was a bit worried that it was the overhead of Ruby, but after digging around, it seems that it's the call to SDL_PollEvent.

Normally it takes far less than a millisecond to complete when there is no input, but when there is, the function can take 1-3ms to complete. Sometimes as high as 5ms.

Am I nuts? Can anyone else confirm this? That is really ridiculous. Spending 10% of the time in a frame waiting for SDL to process input is completely unacceptable.
Quote this message in a reply
Posts: 1,403
Joined: 2005.07
Post: #2
Ive mesured fps and averaged it over the same amount of time (100 timings) with SDL events on and off in a simple OpenGL SDL game im writing.
I got 22.4 fps with events and 23.3 without events.

Except my event code is 64 lines long and deals with executing functions in a seperate script, but none of these events (mouse and keyboard were untouched) were called so that wont have affected the results.

<EDIT: I just noticed somthing funny, were both having speed problems with scriptable SDL games! LOL >

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #3
SDL's events are just Cocoa events... it seems a bit unlikely that they'd be that slow...
Quote this message in a reply
Posts: 1,487
Joined: 2002.09
Post: #4
When I tested it, I disabled everything in my event loop but the call to poll events. The time taken was measured from Ruby, but if make the function call empty it drops down to microseconds.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Occlusion queries... SLOW. TomorrowPlusX 8 7,133 Aug 19, 2005 07:05 AM
Last Post: TomorrowPlusX
  SDL got pretty slow on Tiger? Zeeke 17 13,088 Jun 5, 2005 12:29 AM
Last Post: Kevin Lindeman
  Slow first time draw of textures rzilibowitz 4 5,263 Jan 17, 2005 01:46 AM
Last Post: rzilibowitz
  This thing = way too slow LongJumper 9 7,839 Dec 20, 2004 05:14 AM
Last Post: TomorrowPlusX
  Terribly slow :-( CMagicPoker 7 8,140 Jun 23, 2002 04:06 AM
Last Post: CMagicPoker