Best Benchmarking

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! :wink:

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