Updates: Game Performance
Game performance is a plugin for getting a loop run at a certain speed while returning the maximum time back to the processor. The loop will run at a certain LPS cap or Loops Per Second which also means Frames Per Second. The rest of that time is returned back to the CPU. DBP's sync command doesn't automatically do this but my plugin will return the CPU time back to the CPU so it is running it's fastest. This plugin was created to replace the sync command. I do call fast sync in my plugin just to make sure everything is still updated correctly.
Instead of simply running something in a Do Loop you can set the rate it is executed. This way you can find the minimum amount of times per second it can run. This way you cut a lot of needless calculations per second out of the equation! It is great for For Loop, While Loops, and repeat Until Loop because it can be run at any rate! You can save on performance by using these practices.
All display commands should be run in a loop setup like this:
GP Setup
Index = GP Create Task("DisplayLoop", 60) ` 60 FPS because of FastSync
Do
GP Update
Loop
Function DisplayLoop()
FastSync ` Run sync command here!
EndFunction
Instead of running the display at the maximum rate you can set the display to only run for 60 loops or 60 frames because FastSync will update each frame.
Side Note: Keep in mind these loops are not run in parallel. My multi-threading plugin will be used for this task.
` Sets up the Game Performance Plugin
GP Setup
` Input the functions name which will be representing the loop. The LPS cap which can also be thought of as the FPS is the second parameter.
Index = GP Create Task(FunctionName$, LPSCap)
` This command will update all of the loops that were created. It will run them at the rate that is set. This command will not use Fast Sync so it will be Thread Safe!
GP Update
` This command will return the task type. Count – Will run the loop x amount of times, Time – Will run the loop for x amount of time. Loop – Will loop indefinitely.
Index = GP Get Task Type(Index)
` This command will end the task Index
GP End Task Index
` This command will set the task to run for a certain duration.
GP Set Task To Time Index, Duration
` This command will set the task to run for a certain amount of times.
GP Set Task To Count Index, Count
` This command will set the task to loop indefinitely. By default tasks will loop indefinitely
GP Set Task To Loop Index
` This command will pause the task
GP Pause Task Index
` This command will resume the task
GP Resume Task Index
` This command will stop the task
GP Stop Task Index
New Example:
Rem Project: Performance 2.0
Rem Created: Monday, September 17, 2012
Rem ***** Main Source File *****
Global Count
GP Setup
Sync On : Sync Rate 0
Index = GP Create Task("MainLoop", 30)
//GP Set Task To Time Index, 10
//GP Set Task To Count Index, 10
Index2 = GP Create Task("DisplayLoop", 30)
Do
If InKey$() = "p"
GP Pause Task Index2
EndIf
If InKey$() = "r"
GP Resume Task Index2
EndIf
If InKey$() = "s"
GP Stop Task Index2
EndIf
GP Update
Loop
Function MainLoop()
Count = Count + 1
EndFunction
Function DisplayLoop()
CLS
Text 0, 0, "MainLoop Count: " + Str$(Count)
Text 0, 20, "FPS: " + Str$(Screen FPS())
FastSync
EndFunction
` Dependency function
Function Dependency()
x = Object Exist(1) `Include Basic3D
x = Sprite Exist(1) `Include
x = Particles Exist(1) `Include
x = Vector Exist(1) `Include
x = Memblock Exist(1) `Include
x = Camera Exist(1) `Include
x = Image Exist(1) `Include
x = Effect Exist(1) `Include
x = Sound Exist(1) `Include
x = Mesh Exist(1) `Include
x = Music Exist(1) `Include
x = File Exist("") `Include
x = Matrix Exist(1) `Include
x = Dll Exist(1) `Include
x = Timer()
Call Function Name ""
Wait 1
Nice Wait 1
EndFunction
Time
With a game's time cycle you typically have 24 hours represented in a shorter period of time. You can play the game for like 30 minutes and have played 24 hours game time. With my time plugin you can set the 24 hour conversion to do just that.
DigitalFury