Below are some of my test results
Array & object constructing
When constructing arrays and objects, new array () and new object () are three times slower than [] and {}.
Index Number Type for Arrays
Array numeric index type
Ist [int (0)] is faster than list [0]
Create array vs. Updating Array
Avoid creating arrays multiple times in a recycling statement. It is best to create an array at a time and replace it with the updated content multiple times.
Nulling array vs. Splicing Array
For a large array, the row-based splice operation is costly and should be avoided as much as possible.
When working with large arrays splicing is obviously an expensive operation, you can avoid this by nulling the index and skipping it in a null scenario. if you need to splice in order to keep the array length low. then store these nulled indexes in another trash array once the garbage count has reached a limit you 've defined loop through the numerically sorted trash indexes deleting splices in bulk. this concept is demonstrated in tweensy.
Nulling object vs. Delete object
Deleting an object attribute is more expensive than setting this attribute to null. Therefore, it is best to set this attribute to null.
Nesting loops (nested loop)
The efficiency of multiple nested loops is poor, so it is best to ensure that the loops are within two layers.
Inline code vs. Function references
If the function on the time frame is long and the execution time is long, it is best to divide the function into multiple small functions for execution.
This can shorten the execution time and improve the efficiency.
Arguments vs. Variable referencing
Minimize the number of function parameters
Function apply scoping do it or not?
Scoping function. Apply Is a little bit slower than not so if you don't have to then don't.
Array Push Vs. Array Index
Use the index setting method instead of the Array Function push.
For example
List [list. Length] = data; 600% faster than direct push;
Array emptying-length 0 vs. A new array
If you need to set an empty array, you can easily select it by setting its Length attribute to 0.
Or you may think this is a good choice because it can save memory, but in fact the execution speed is not as efficient as the direct new array.
Of course, if you need to clear more than 510 empty arrays in a loop, it will be better to set the length to 0.
VaR declarations on multiple lines vs. var declarations on a single line
Declaring variables in one row is better and more efficient than declaring multiple rows.
I. e.
VaR A: Int = 0, B: Int = 0, C: Int = 0;
Vs.
VaR A: Int = 0;
VaR B: Int = 0;
VaR C: Int = 0;
Using XOR to swap VariablesIf you want to exchange variables without creating new variables, you can use XOR
For example:
A = a ^ B;
B = a ^ B;
A = a ^ B;
Multiplication vs. Division
The speed of multiplication is always faster than that of departure, for example, 5000/1000.5000*0.001 fast 130%;
Type Casting comparison forced conversion type comparisonWhen type casting the keywordAs
Is 250% more efficient than castingType (item );
Though surprisingly not using either is about 1400% more efficient.
We recommend that you use corresponding types of variables for comparison.
The same type is more efficient.
Long vs short variable names
Use a short variable name whenever possible