Get the run time interval for every functions in scene

Typically: "How do I... ", "How can I... " questions
Post Reply
zhangm365
Posts: 46
Joined: 19 Jun 2021, 12:58

Get the run time interval for every functions in scene

Post 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.

coppelia
Site Admin
Posts: 10378
Joined: 14 Dec 2012, 00:25

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

Post 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

Post Reply