Benchmarking is used to check the performance of code. I use os.clock()
lua local startTime = os.clock() -- code -- local deltaTime = os.clock() - startTime print("Elapsed time: ".. deltaTime
, but I wonder if there is a better way assess the performance. Like using tick() or something else. Responses would be appreciated!
3 Likes
os.clock()
is probably the best was to benchmark, since itโs the most accurate way of telling time. I made a module to help with benchmarking my code, which I donโt use that often, but when I need it, itโs there. For my .NET C# Lua console, I was able to add my module, the time module, to help with benchmarking.
No, actually os.clock
is made for things like benchmarking. This is what the wiki says:
Returns the amount of CPU time used by Lua in seconds. This value has high precision, about 1 microsecond, and is intended for use in benchmarking.
3 Likes