[SDL] threading overhead

Garrett mongoose at WPI.EDU
Sun Apr 9 14:55:59 PDT 2000


  How did you time your code?

On Sun, 09 Apr 2000, you wrote:
> Pierre Phaneuf wrote:
> 
> > > Yes , you right. And you can control timeouts on nonblocked accept of
> > > cource. But threads on SMP machines give you more perfomance.
> > 
> > A few points:
> > 
> >  - not many people have SMP machines, and more running threads/processes
> > than there are CPU causes a noticeable overhead
> 
> Could some people look at this test program and tell me if I did
> questionable things? I compile threaded and non-threaded version with
> these command line:
> 
> gcc -o test1 thread-test.c 
> gcc -o test2 -DTHREADED -lpthread thread-test.c 
> 
> Running each one five times in a row gives me these results on my
> machine:
> 
> Running time: 35475 ms (single-threaded)
> Running time: 35458 ms (single-threaded)
> Running time: 35447 ms (single-threaded)
> Running time: 35658 ms (single-threaded)
> Running time: 35528 ms (single-threaded)
> 
> Running time: 40457 ms (multi-threaded)
> Running time: 39970 ms (multi-threaded)
> Running time: 38569 ms (multi-threaded)
> Running time: 39422 ms (multi-threaded)
> Running time: 40173 ms (multi-threaded)
> 
> Notice the 4-5 seconds more time it takes to execute and the variance
> with the multi-threaded version.
> 
> I was expecting this, but I was wondering if any multithreading
> proponent had anything to say on my code?
> 
> -- 
> Pierre Phaneuf
> http://ludusdesign.com/
-- 
-Garrett,  WPI student majoring in Computer Science
"The fastest way to succeed is to look as if you're playing by somebody
else's rules, while quietly playing by your own." -Michael Konda



More information about the SDL mailing list