|
Clocking tutorial - fps test program |
TurboJudas
Member #7,039
March 2006
|
the Clocking Tutorial by Cage clocking.html puzzled me quite a bit at first, so I had to make a test program. You can download the test exe:s and source code here: http://www.cc.puv.fi/~e0400536/clocktest.rar My 1,8Ghz computer draws the screen 450fps fullscreen and 220fps windowed, using 98% cpu.when adding sleep(1); after the drawing is finished the fps drops to 63 - 64 fps, using 0 - 2% cpu. I find it somewhat puzzling that if I start eg. midinotate or realplayer the fps rises to about 115. My friend tested the clocktests on his 700Mhz pc, both the sleep(1) and nosleep fullscreen tests ran at about 75fps, and the windowed tests at about 40fps. conclusion: here is the source code:
|
hazul
Member #4,338
February 2004
|
is the same as
* * * * * |
TurboJudas
Member #7,039
March 2006
|
Thanks, I knew there would be a better way for that I´ll change it right away. Machinae Supremacy rules btw! and I just love the sounds of the sid chip! |
Birdeeoh
Member #6,862
February 2006
|
My 1,8Ghz computer draws the screen 450fps fullscreen and 220fps windowed, using 98% cpu.when adding sleep(1); after the drawing is finished the fps drops to 63 - 64 fps, using 0 - 2% cpu. I find it somewhat puzzling that if I start eg. midinotate or realplayer the fps rises to about 115. The problem with sleep() is it's very low res, low accuracy. Sleep(1) actually means "sleep AT LEAST 1 millisecond". On Windows it's often 5, 10, even 15 ms. In my exp when I have a 60hz refresh rate and I insert a Sleep(1), the app usually wakes right around 60hz - sometimes dead on, sometimes up to 65 like you experienced. This means, at the very least, the OS driven refresh rate will force your program awake that often. It does make sense to me that starting another program which does something involing graphical timing will actually speed your program up as it causes more interupts which become opporunities for the OS to reschedule your process. Makes me wonder if there'd be a reliable way to do a Sleep(1) but have a second thread which causes some regular event to force the OS to wake your process... that way we could get rid of the pesky 100% CPU usage but also get faster than-refresh-rate timing... hmmmmmm [url http://developer.berlios.de/projects/openlayer/]OpenLayer[/url is an OpenGL accelerated 2D library for fast and easy graphics development under Allegro |
gnolam
Member #2,030
March 2002
|
Well, there is always TimeBeginPeriod()... -- |
miran
Member #2,407
June 2002
|
Quote: Well, there is always TimeBeginPeriod() [msdn.microsoft.com]... Always? -- |
A J
Member #3,025
December 2002
|
use TimeBeginPeriod() to set the resolution of Sleep() to 1. ___________________________ |
gnolam
Member #2,030
March 2002
|
Miran said: Always? It's a set expression. -- |
HoHo
Member #4,534
April 2004
|
Quote: Well, there is always TimeBeginPeriod() It should ba always under Windows. Under *nix you have gettimeofday that is much better for timing __________ |
gnolam
Member #2,030
March 2002
|
The post I was replying to was only talking about Windows... -- |
|