|
Performance problems in Allegro 4.2.1.0 |
DarkDragon
Member #8,337
February 2007
|
Hi, |
Kitty Cat
Member #2,815
October 2002
|
Not without seeing code. Things to check are, make sure you call release_bitmap whenever you call acquire_bitmap (and don't use any non-drawing routines between them), don't use rest() or the like to time your main loop (use timers), etc... -- |
Richard Phipps
Member #1,632
November 2001
|
Can you show us your 'busy loop'? |
DarkDragon
Member #8,337
February 2007
|
EDIT: What are the code tags on this board? void update_logic_counter() void throttleFPS() { void throttleFPS() { |
Evert
Member #794
November 2000
|
Quote: EDIT: What are the code tags on this board? Check the HELP link above the area where you type your message. In particular, they are lower case. Your code looks okish, however, I would do it slightly differently:
It's pseudocode, but it's almost exactly the code I use. |
DarkDragon
Member #8,337
February 2007
|
Changing the timer to fire once per millisecond, and replacing the timing code with the following
I get the following results: |
kazzmir
Member #1,786
December 2001
|
Quote: Changing the timer to fire once per millisecond You cannot get this level of timing with Allegro timers. Most OS's return about 10 millisecond precision. I think there are some native calls you can make to get better results. |
DarkDragon
Member #8,337
February 2007
|
Fair enough. static long lastlow; void throttleFPS() { LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); LARGE_INTEGER currtime; QueryPerformanceCounter(&currtime); while(logic_counter < 1) rest(1); QueryPerformanceCounter(&currtime); long newtime = (currtime.LowPart*1000)/freq.LowPart; lastlow = newtime; logic_counter = 0; } The following is an excerpt of the output: before: 7 Overall what I'd expect, with some anomalies, as you can see, near the end, causing choppy game play. |
Kris Asick
Member #1,424
July 2001
|
Replace rest(1) with rest(0). That should do it. However, doing this will cause CPU usage to spike. (As you are no longer giving up big chunks of CPU time to the OS.) Calling rest(1) can lose anywhere from 1 ms to over 20 ms to the OS, which will completely mess with your timing. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
DarkDragon
Member #8,337
February 2007
|
That seems to have helped! Thank you. |
|