Calculate run/execution time

Typically: "How do I... ", "How can I... " questions
Post Reply
ik-123
Posts: 10
Joined: 26 Jan 2020, 13:39

Calculate run/execution time

Post by ik-123 »

Hello,
I have developed motion planning functionality(in a threaded child script), and I would like to measure the performance of this planning function. I am thinking of using the run time as a measure. Is there a way in coppeliaSim to calculate the run/execution time of a specific block of code in a child script?
Cheers,

fferri
Posts: 1222
Joined: 09 Sep 2013, 19:28

Re: Calculate run/execution time

Post by fferri »

Hi,

you can simply do

Code: Select all

local t_start=sim.getSystemTime()
-- long computation ...
local t_end=sim.getSystemTime()
local elapsed=t_end-t_start

ik-123
Posts: 10
Joined: 26 Jan 2020, 13:39

Re: Calculate run/execution time

Post by ik-123 »

Thank you for your answer. But is there a definition for the time used, does it depend on the system architecture (CPU, RAM,..)?
Another important question how can I measure the computational effort or the CPU utilization for this function in CoppeliaSim?
Thank you a lot for the constant support and engagement.

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

Re: Calculate run/execution time

Post by coppelia »

If you use sim.getSystemTimeInMs then you can see what kind of underlying API functions are used. But basically, those functions only make sense to measure time differences. No absolute times.

About the computational effort... that is more difficult. Probably there is a tool that allows to inspect those values with more details than what is available on Windows task manager for instance.

Cheers

Post Reply