1

I'm trying to plot some graphs simultaneously: Each representing an attribute and displays the results for several objects each containing its own data items series. I encounter very bad performance using either add(...) or addOrUpdate(...) methods of the TimeSeries - time for plotting ~16,000 items is about 60 seconds. I read about the performance issue - http://www.jfree.org/phpBB2/viewtopic.php?t=12130&start=0 - but it seems to me like it is much worse in my case for some reason.

  1. I'd like to understand whether this is truly the performance that I may squeeze out of the module (2.5GHz machine running windows - I doubt that).
  2. How can I get my application accelerated with this respect?

Here is a basic version of the code (note that it is all done in a dedicated thread):

/* attribute -> (Object -> graph values) */
protected HashMap<String,HashMap<Object,Vector<TimeSeriesDataItem>>> m_data = 
  new HashMap<String,HashMap<Object,Vector<TimeSeriesDataItem>>>();

public void loadGraph() {
    int items = 0;
    for (String attr : m_data.keySet()) 
        for (Object obj : m_data.get(attr).keySet())
            for (TimeSeriesDataItem dataItem : m_data.get(attr).get(obj))
                items++;
    long before = System.currentTimeMillis();

    // plot each graph
    for (String attr : m_data.keySet()) {  
        GraphXYPlot plot = m_plots.get(attr);
        plot.addToObservation(m_data.get(attr));
    }

    System.err.printf("Time for plotting %d items is:  %d ms", items, System.currentTimeMillis()-before);
    // => Time for plotting 16540 items is:  59910 ms
}

public void addToObservation(HashMap<Object, Vector<TimeSeriesDataItem>> plotData) {
    for (Object obj : plotData.keySet()) {
        SeriesHandler handler = m_series.get(obj);
        if (handler != null) {
            TimeSeries fullSeries = handler.getFullSeries();
            TimeSeries periodSeries = handler.getPeriodseries();
            for (TimeSeriesDataItem dataItem : plotData.get(obj)) {
                fullSeries.add(dataItem);
                periodSeries.add(dataItem);
            }
        }
    }
}

Thanks a lot !

Guy

Guy Gaziv
  • 19
  • 5
  • Please edit your question to include an [sscce](http://sscce.org/) that would allow others to repeat your experiment. – trashgod Dec 20 '12 at 17:35

1 Answers1

1

Absent more details, any of several general optimizations should be considered:

  • Invoke setNotify(false), as suggested here.

  • Cache already calculated values, as discussed here.

  • Adopt a paging strategy, as shown here.

  • Chart a summary of average/time-unit values; based on the ChartEntity seen in a ChartMouseListener, show an expanded subset in an adjacent panel.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045