Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance problems when iteratively adding points #1

Open
xpromache opened this issue Apr 24, 2012 · 2 comments
Open

Performance problems when iteratively adding points #1

xpromache opened this issue Apr 24, 2012 · 2 comments

Comments

@xpromache
Copy link

I'm using the InvientCharts with Vaadin and I want to make a line chart to which I add a new data point each second.
The problem is that the InvientCharts.addPoint operation takes around 0.5ms x number of points in the graph. Also the getPoints takes around the same time. So by the time i have a few hundreds points in the graph, the thing becomes unusable.
I need to be able to store a few thousands points.

@xpromache
Copy link
Author

btw, please see below the stack trace while the getPoints is running.
Basically adding points into a hash involves doing lots of calendar operations.

at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:434)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2098)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2013)
at java.util.Calendar.setTimeInMillis(Calendar.java:1126)
at java.util.GregorianCalendar.<init>(GregorianCalendar.java:593)
at java.util.Calendar.createCalendar(Calendar.java:1028)
at java.util.Calendar.getInstance(Calendar.java:965)
at com.invient.vaadin.charts.InvientCharts.getDateInMilliseconds(InvientCharts.java:363)
at com.invient.vaadin.charts.InvientCharts.access$0(InvientCharts.java:359)
at com.invient.vaadin.charts.InvientCharts$DateTimePoint.equals(InvientCharts.java:2900)
at java.util.HashMap.put(HashMap.java:393)
at java.util.HashSet.add(HashSet.java:217)
at java.util.AbstractCollection.addAll(AbstractCollection.java:322)
at java.util.LinkedHashSet.<init>(LinkedHashSet.java:169)
at com.invient.vaadin.charts.InvientCharts$Series.getPoints(InvientCharts.java:3173)
at com.invient.vaadin.charts.InvientCharts$DateTimeSeries.getPoints(InvientCharts.java:3647)

@danhallin
Copy link

My solution was to create an override of the series class, the updatePointXValuesIfNotPresent-function is called for every addPoint and does a lot of unnecessary work if you have x-values defined on your points:

public class ModifiedDateTimeSeries extends InvientCharts.DateTimeSeries {
...
protected void updatePointXValuesIfNotPresent() {
// do nothing
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants