adam bien's blog

1 Million Rows In A JTable - Or How To Convince C++ Developers 📎

Sometimes it is necessary to perform more dramatic steps to convince C++ developers about Java performance. We developed a JTable with custom model, renderers and editors to port an existing C++ application. We begun with tests, as some of the C++ developers expressed his concerns about the performance and resource usage of the current solution. The old C++ application was able to handle few thousands rows in a table. Instead of discussing the performance of Java we started a spike with 5000 rows in a three row table. The last column consisted of a JComboBox with own model pointing to another 5000 records. It took less than one second to load the table. We increased the number to 50.000 records it took few seconds to load the data and open the application. The we only wanted to break the application and increased the data to 1 million records. ...after about 40 seconds and 1GB heap usage the app opened - it was slow but usable. It is really remarkable because we performed the test without any optimizations. The application was built in object oriented way the domain objects were constructed from REST-like (not really RESTFul) data stream, and were wrapped with a custom table model. Custom renderers and editors were responsible for displaying the data. Every table cell was displayed by a renderer which exposed a domain object. So several instances were involved for a single cell.

We repeated the test within Netbeans Profiler and were able to identify some bottlenecks (unfortunately some of them were written by me...:-)).