Re: Optimizing basic operations
- Posted by Spock Aug 02, 2013
- 5737 views
When the loop exits list will contain the top 100. shufflelist() simply inserts "this" somewhere in list and drops the last element.
I see. What you're saying is that the time spent doing a shufflelist() plus finding the lowest eval would be faster than a true sort plus lowest_eval = sorted_eval_list[$][1].
Yes. shufflelist() should be faster than sort() but the efficiency of that part of the program is a minor issue since it will be called so infrequently. The overall processing time will be dominated by the trillions of comparisons needed inside the main loop.
The difference between choosing sort() or shufflelist() might mean the difference between a processing time of 10 hours versus 10 hours and 2 seconds. A much bigger concern is the derivation of the data structures in the first place. Tell us about that, there could be some sizeable gains to be had.
regards, Spock