fps & different CPUs

Blitz3D Forums/Blitz3D Programming/fps & different CPUs

jtassinari(Posted 2010) [#1]
Hi everyone,

as i have tried a little exe on differnt cpus i have seen it's running at different FPS.

So i thought that if i could set a specific FTP, according to the HW chances, i could see my little app running quite fine...

but still, how can i do it?

any suggestion would be really welcome...

thanks

jTassinari
-[ www.absolute-line.net ]-


Kryzon(Posted 2010) [#2]
The native Timer commands are supposed to provide a simple way to make your application run on different systems with the same speed.

There are other manual ways, of course, like Tweening or Delta Timing. It all comes down to what result each method has, and if that result is what you seek.

Further reading: http://www.blitzbasic.com/Community/posts.php?topic=85383


Charrua(Posted 2010) [#3]
hi

when i tried to understand frame tweening i made an adition to the sample code, just a bargraph showing how Frames per second and game uptades per second vary depending on the complexity of the 3d world or quantities of objects to render etc.



try this code, change the ammount of cubes to show, use the left/right arrows to rotate the camera and see how the white bar (game updates) remains constant and the red one (renders per second) change as the invers of the ammount of cubes in front of the camera.
the graph also shows the acumulative of UpdateWorld, RenderWold and Update game.

Juan


jtassinari(Posted 2010) [#4]
thansk Kryzon,

your suggestion sounds perfect to me, i wonder how's this is gonig to load the CPU, BTW there is a great way to learn... Testing :D


cheers,

jTassinari
-[ www.absolute-line.net ]-


jtassinari(Posted 2010) [#5]
Kryzon,
i tried the CreateTimer function but it takes the (one of the two) cpu at full usage!

browsing around in the programming area, i got this post (http://www.blitzbasic.com/Community/posts.php?topic=23175#238864) that is offering a great solution to fix the framrate and free the CPU charge.

doing this i still can have the change to send and recive datas on the net od to a db to store info.

While Charrua, your scritp is really nice, and really well explained, thansk indeed =)

cheers,


jTassinari
-[ www.absolute-line.net ]-


*(Posted 2010) [#6]
I would recommend Delta timing over the blitz build timing functions, not only do the inbuilt functions suck away CPU time but with Delta time you can have the system do things inbetween frames.


Kryzon(Posted 2010) [#7]
The timer commands do not waste CPU resources with blank loops. They free it just like if you used Delay.


[...] not only do the inbuilt functions suck away CPU time [...]

Where did you read that?

Run this:
timer = CreateTimer(1)

While Not KeyHit(1)
   
   If KeyDown(57) Then WaitTimer(timer)

   Print n
   n = n + 1

Wend

End
Hold space to see the effect of WaitTimer. Make sure you got the TaskManager minimized so you can see the CPU usage in the tray.

The real danger are manual methods that rely on blank loops to wait for time to pass, even if that time is nothing more than 1 or 2 milliseconds. Logically, waste is waste, no matter the amount.


*(Posted 2010) [#8]
years ago when I used the inbuilt commands I used CreateTimer/WaitTimer and the game didnt run as fast as when I used Delta Timing. This was years ago so they might be better now :)


jtassinari(Posted 2010) [#9]
Hi there,

i did some more testing, and had closer cpu usage in both case.
I tested a simple script with a lot of Sin and Cos and entitydistance, in both cases, a simulation of soral system, with hi color texture, on intel 2 core and intel 2 quad core.
In both cases the cpu worked fine, on the compiled script, and the cpu usage was around 7% on dual core (one cpu working) and 4% on intel2 quad (always one CPU working).

Now it's just as scipting is working better according to the understaing of it...

cheers,


jTassinari
-[ www.absolute-line.net ]-


_33(Posted 2010) [#10]
Blitz3D will always just use ONE cpu core, as the language is single threaded. So it is normal that you get twice the cpu usage on a dual core than on a quad core. But I am not sure what your question is from the base of this thread. It's obvious that everyone that will run your program will have various CPUs (INTEL or AMD) at various speeds. You on the other hand need to level it out with the right methods (like what Kryzon proposed for example).


_PJ_(Posted 2010) [#11]
Full CPU load will be assigned to a B3D app regardless of the frame limiting methods, the thread ha the CPU availabilitiy even if the workload is much less than the processor's capability.
To free up the CPU, just add in a small (i.e 1 - 10 maybe?) Delay in the loop. This will halt execution briefly when the CPU can continue with other priority tasks.

* for a single core only of course.