I'm trying to measure time of my code execution with the os.time() function and display it with LOVE framework. But, to my surprise, the displayed times are changing... My code is:
function foo()
start_time = os.time()
<some code>
end_time = os.time()
elapsed_time = os.difftime(end_time-start_time)
love.graphics.print('start time: ' .. start_time .. 's', 12, 12)
love.graphics.print('end time: ' .. end_time .. 's', 12, 22)
love.graphics.print('time elapsed: ' .. elapsed_time .. 's', 12, 32)
end
When I leave the window with my graphics open the times are changing (start and end growing and the difference changes between 1 and 2) - so the first question is how does that happen if os.time() returns a number. And also - is that a good way to measure the execution time of my application?