Before that, check the performance tips of the manual.
First of all, put all the critical code in a function and do not use global variables.
Before that, check the performance tips of the manual.
First of all, put all the critical code in a function and do not use global variables.