I have resisted actually posting the code because it has been suggested to me that the app should be looked at for a patent, and this calculation process is at the heart of the idea. So I have reduced the variables down to just generic names so as not to give away my idea away. I really liked your idea of combining all of the conditionals to one line using && operators, but in the end it was no faster. Two minutes and forty seconds to complete. I believe this is because, in my code, I have placed the conditionals in an order that is most likely to throw out a record quickly if it is not a good comparator, whereas your idea forces all of the conditionals to HAVE to be considered for EVERY record(at least I think that it does). Here is a simplified version of the code:
protected function recalculateHandler(event:Event):void { processingPU.removeEventListener("popUpOpened", recalculateHandler); var count:int = 0; var average:Number = 0.0; var someNumberl:Number = 0.0; var lon1:Number; var lon2:Number; var lat1:Number; var lat2:Number; var dlon:Number; var dlat:Number; var a:Number; var c:Number; var d:Number; var tempDist:Number = (distance.selectedIndex*.25)+.25; var length:int = mainArrayCollection.length; var tempArray:Array = new Array(); compArrayCollection = new ArrayCollection(); tempCompArray = new Array(); tempArray = speedArrayCollection.source; for (var i:int = 0; i < length; i++) { /* Loop Through Each of the Records*/ if (tempArray[i].status == "Act") { /* Test to see if current record status is ACTIVE */ for (var j:int = 0; j < length; j++){ /* Compare to Each of the other Records*/ if (i != j) { /* Make sure you are not comparing a record to itself */ if (tempArray[i].propOne == tempArray[j].propOne) { if (tempArray[i].propTwo == tempArray[j].propTwo) { if (tempArray[i].propThree == tempArray[j].propThree) { if (Math.abs(tempArray[i].propFour - tempArray[j].propFour) <= 10) { if (tempArray[i].propFive == tempArray[j].propFive) { if (Math.abs(tempArray[i].propSix - tempArray[j].propSix) <= 1) { if (Math.abs(tempArray[i].propSeven - tempArray[j].propSeven) <= 1) { if (Math.abs(((tempArray[i].propEight - tempArray[j].propEight)/tempArray[i].propEight))<0.10) { lon1 = tempArray[i].longitude*Math.PI/180; lon2 = tempArray[j].longitude*Math.PI/180; lat1 = tempArray[i].latitude*Math.PI/180; lat2 = tempArray[j].latitude*Math.PI/180; dlon = lon2 - lon1; dlat = lat2 - lat1; a = Math.pow(Math.sin(dlat/2), 2) + (Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin(dlon/2), 2)); c = 2*Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); d = 3961 * c; if (d <= tempDistance ) { count = count + 1; someProp = someProp + Number(tempArray[j].propEleven); tempCompArray.push({" push about 26 properties from one array to a comparison array, plus some new values}); tempArray[i].propTwelve = istrue; } } } } } } } } } } } if (count != 0) { /* Populate data if there is actually data to be updated */ average = someProp/Number(count); tempArray[i].propThirteen = count; tempArray[i].Prop14 = average; if (average == 0.0) { tempArray[i].propFourteen = 0.0; } else { tempArray[i].propFourteen = (Number(tempArray[i].propTen) - average)/average *100.0; } tempArray[i].propFifteen = tempArray[i].propFourteen - tempArray[i].propFifteen; } count = 0; average = 0.0; someNumber = 0.0; } } PopUpManager.removePopUp(processingPU); compArrayCollection.source = tempCompArray; mainArrayCollection.source = tempArray; } -- View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Workers-and-Speed-tp13098p13192.html Sent from the Apache Flex Users mailing list archive at Nabble.com.