If you are working on a script which is running slowly you can use the
os.clock() function to help locate which part 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.
When using it in the editor you can view the times in the annotations:
For live code use
iguana.logDebug() and use the debug logging level when you need to profile:
If you want more information you can always use a profiler like pepperfish.
Tuning Tips [top]
Because all interfaces are different there are no cut and dried tuning solutions. Basically once you have identified the bottlenecks, you need to figure out how to make them go faster.
Here are a few helpful tuning techniques. Pipelining (or batching) can be helpful for high message throughput, this can dramatically speed up writing to databases (by reducing disk writes and network overhead), and it is also useful for web services (as it reduces connection overheads). If you are writing output to disk files be sure to archive old output files (either delete or move older files), to reduce operating system overheads.
- Pipe-lining by batching messages, for faster performance writing to databases etc.
- Getting high message throughput with REST
- How to improve performance when writing a large number of message files to disk
- Profiling your Lua script using pepperfish