Finding bottlenecks
Contents
If you are working on a script which is taking too long to run and timing out, then this is a simple trick for quickly locating the part which is slow:
The os.clock()
function returns the approximate time the cpu has been running (with millisecond accuracy), which makes it easy to see how long a piece of code is taking.
Once you have located a slow section there are many ways to deal with the issue, the following pages demonstrate two of these.
Tip: You can adapt this technique for optimizing live code by logging the time instead:
Continue: Faster Editor code execution