On 7/30/16, 11:13 PM, "Justin Mclean" <jus...@classsoftware.com> wrote:
>Hi, > >> for (length of array collection = 38k) >> for (length of array collection = 38k) >> if condition one is met >> if condition two is met >> if condition three is met >> if condition four is met >> if condition five is met >> if condition six is met >> if condition seven is met >> if condition eight is met >> if condition nine is met >> if condition ten is met >> [Do a whole lot of trig calculations] > >There probably a lot of ways this can be optimised: >- make sure the lengths are collated out side of the loops and not each >time around/inside the loop >- if the array collection is bindable (I hope not) turn off updates >- loop around the array inside the array collection not the array >collection itself (this I’d guess give a significant performance increase) >- are the conditions in increasing order of cost / can the order be >changed? >- if the arrays were sorted in some way would you need to loop over it >twice? >- can the calculations be cached in some way? >- are there any string manipulation or other temporary variable being >created causing frequent garbage collection? > >I’s suggest you run scout over it to see what is taking the most time and >see if that can be optimised. Yep, profiling should help you find out whether the condition testing is a factor or if it is just the trig. Similar to Justin's caching suggestion, can the results of the past run be stored somewhere so only the new records need to be tested? If there are no "else" clauses, storing conditions as a bit field might be faster if the condition testing is a factor at all. If the trig is the issue, then you have to look at the trig and determine how much of it can be run in parallel. -Alex