Page 1 of 1

Get the run time interval for every functions in scene

Posted: 03 Mar 2022, 03:56
by zhangm365
Dear admin:

How to get the accurate run time interval for every function(i.e, sysCall_sensing) in scene script?

I have try getSimulationTime in one function, the delta time is zero. For the getSimulationTimeStep?

Best Wishes.

Re: Get the run time interval for every functions in scene

Posted: 03 Mar 2022, 09:14
by coppelia
Hello,

try with:

Code: Select all

function sysCall_sensing()
    local startTime=sim.getSystemTimeInMs(-1)
    
    -- Do something here
    
    print(string.format("Time spent: %i [ms]",math.floor(sim.getSystemTimeInMs(startTime))))
end
Cheers