|Summary:||Slow Aggregate Report Performance / org.apache.jorphan.math.StatCalculator|
|Product:||JMeter||Reporter:||Jared Sulem <jared>|
|Component:||Main||Assignee:||JMeter issues mailing list <issues>|
|Attachments:||Use LinkedList instead of ArrayList in org.apache.jorphan.math.StatCalculator|
Description Jared Sulem 2009-05-19 15:38:20 UTC
Created attachment 23695 [details] Use LinkedList instead of ArrayList in org.apache.jorphan.math.StatCalculator JMeter slows to a crawl and eventually becomes completely unresponsive as it accumulates samples using the Aggregate Report. The issue appears to be that the StatCalculator uses an ArrayList to store the samples and inserts them within the list to keep the list sorted. ArrayList has O(n) performance for insertions at arbitary locations in the array (n is the current size of the list). This means that over the entire JMeter run performance of JMeter with an AggregateReport is at least O(n-squared). Changing the ArrayList to a LinkedList significantly improves the performance. Although a LinkedList is still O(n) for sorted insertions (and for operations such as reading the median and 90% values), the constants for these operations are significantly lower than that of inserting into an ArrayList (probably because the LinkedList never needs to copy the whole array in order to insert an item). After this change JMeter becomes usable for collecting tens of thousands of samples, whereas before it would bring my system to a complete halt. I've attached a small patch to the bug that changes the ArrayList into a LinkedList in StatCalculator.