Log In  

Is there documentation for exactly how many clock ticks instructions take to execute? In those unfortunate situations when fps drops from 30 to 15, it is challenging to find ways to be more efficient without that information.

Or perhaps a function to return clockticks since last display?

Thanks for any info,
RGB

P#18679 2016-02-06 23:02 ( Edited 2016-02-10 02:28)

stat(1) may help...?

From the manual:

stat x
x:0 returns current memory useage (0..256)
x:1 returns cpu useage for last frame (1.0 means 100% at 30fps)

P#18709 2016-02-07 17:43 ( Edited 2016-02-07 22:44)

It needs to be checked but I think you can call stat(1) anywhere in your code to get the frame percentage since the start of it. So may be you can "delta" some parts of your code.

P#18730 2016-02-08 10:53 ( Edited 2016-02-08 15:53)

The stat() routine seems a little inaccurate. This code uses a busy loop to demo what 30fps (COUNT=970) looks like versus 15fps (COUNT=1050). However, when COUNT=970, it produces 30fps display, but stat() says the cpu is at 105%. Is this expected?

tick = 0;
count=970;

function _init()
end

function _update()
tick += 1
if (tick > 30) then tick=0 end
end

function _draw()
 cls()

for i=1,30 do
xx = -cos(i/30)
yy = sin(i/30)
line(xx*52+64,yy*52+64,xx*55+64,yy*55+64,8)
end

 for i=1,count do
  spr(0,10,20)
 end

xx = -cos(tick/30)
yy = sin(tick/30)
line(64,64,xx*50+64,yy*50+64,7)

str="stat: "..stat(1)
print(str,2,2,7)
end
P#18757 2016-02-09 21:28 ( Edited 2016-02-10 02:28)

[Please log in to post a comment]