Performance Tips

The script language is not designed to process huge amount of data or to perform heavy CPU computation. It is a language designed for simplicity, not for performance, but here are some tips to speed up scripts.

1. Searching a Pattern

To search a pattern in a text file, use Finder to find something. Do not try to re-implement a scan function, it will be more difficult to implement and it will be slower.

2. Comparing Text with a Pattern

Use the match method of the Finder class to check if a portion of text matches a pattern instead of reading the text line: accessing the text of the row creates a copy of the text into the heap.

3. Use Local Variables

Avoid using accessor methods multiple times: it requires a method lookup and on native properties, it can reallocate a new wrapper object or a new string on the heap.

4. Complex Computations

If you need to do heavy CPU computation, start an external program written with a more efficient language to do the job.