Improving performance for huge datasets - (autosort)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
apanag
Posts: 6
Joined: Wed Apr 05, 2006 2:43 pm
Location: Zürich
Contact:

Improving performance for huge datasets - (autosort)

Post by apanag » Thu Mar 27, 2008 6:08 pm

Hi all,

I create a huge dataset with 1 million Points (a scatter plot, but this is not so important).
It used to take me 20 seconds on Mac Book Dual Core 2 - 3G ram.

I've noticed that trying to add all my points one by one to XYSeries was the bottleneck. I've switched off the notify, but still no huge difference.
my code:
for(...){
series.add( x, y, false)
}
series.fireSeriesChanged();

By examining the source code I found the solution:
Switch off the autosort, which calls a "binarySearch" everytime you add a point - no matter what is the notify listeners state, and tries to add the point after any duplicates.

My data is already sorted, so no problem at all.

So, I create the XYSeries like this:

XYSeries series = new XYSeries(seriesTitle, false);

The process takes now only half a second.
Hope it helps.

Andreas

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Mar 27, 2008 6:43 pm

If you have that many data values, XYSeries is not the most efficient dataset...you could save some memory by using DefaultXYDataset, unless you need some of the flexibility of XYSeries.

Later, of course, you'll run into some other inefficiencies in JFreeChart with plotting 1 million data points. Hopefully we can address a few of those during 2008.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

deepujain
Posts: 21
Joined: Sat Jun 02, 2007 10:52 am
Location: Bangalore

Post by deepujain » Fri Mar 28, 2008 11:00 am

I plot around 50+ [can go to 100] graphs and for each graph i have new XYSeries("Label") and each series i add to XYSeriesCollection(). I later use this collection to draw timeseries graph and when i add the data into the series i would have already sorted it. So will using the same logic new XYSeries("label",false). help the performance in this case as well?
Thanks
Deepak
Zzzzz....

Locked