Mike Simmons wrote:Are you asking if it's possible that floating point calculations are the bottleneck in your program? Sure, I suppose it's possible. Hard to tell really, but it's always possible for something to be a bottleneck if it's repeated enough times in a tight loop. However, looking at your method, I might first consider that the biggest performance hit comes from the use of a Map, _weightedMap. Considering both the key and value are primitives, this results in a lot of boxing and unboxing, in addition to the hashing and lookup. And considering you assume that all possible key values will have a weight entry (else there would be a NullPointerException) - could you perhaps just use a float array instead? Where the key becomes the index of the array? (You might have to add an offset to ensure the index is positive.) I suspect this would eliminate your biggest current bottleneck. Might be worth a try, at least.