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

Series construction is very slow #65

Open
nishikantparmariam opened this issue Jul 16, 2024 · 3 comments
Open

Series construction is very slow #65

nishikantparmariam opened this issue Jul 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@nishikantparmariam
Copy link

Description

Construction of series objects is very slow even for array input. Our use-case requires adding multiple series to chart having ~10k points each. A single series seems to take 3 seconds.

Reproducer

from datetime import datetime
from highcharts_stock.chart import Chart
from highcharts_stock.highcharts import AreaSplineRangeSeries, LineSeries

x = list(map(datetime.fromtimestamp, range(630892800, 1686787200, 86400)))[:10000]
low = list(range(len(x)))
high = list(range(500, 500 + len(x)))
data = list(zip(x, low, high))
%%time

chart = Chart()
chart.add_series(AreaSplineRangeSeries(data=data))

image

Version

highcharts-stock == 1.7.0
highcharts-core == 1.8.2

@nishikantparmariam nishikantparmariam added the bug Something isn't working label Jul 16, 2024
@nishikantparmariam nishikantparmariam changed the title Series Construction is very slow Series construction is very slow Jul 16, 2024
@hcpchris
Copy link
Collaborator

Thanks, @nishikantparmariam , and sorry you're running into some slow performance here. One question: Are you running this in a context where you have NumPy installed?

We introduced some major performance improvements awhile back that have a soft dependency on NumPy (i.e. if NumPy is available in the environment, it should result in significant performance improvements) If however you are seeing this poor performance in an environment where NumPy is present, then that will require some further investigation to see what's happening.

@nishikantparmariam
Copy link
Author

Yes, numpy is present in my virtual env.

@hcpchris
Copy link
Collaborator

Hmm - thanks for confirming that. I'll need to look into this, because if NumPy is present in your environment:

  1. Series construction should be vectorized.
  2. Serialization of series via .to_js_literal() should create a list of lists rather than a list of dict if the data points are not utilizing "special" properties.

All of which should provide a very significant performance boost. So this suggests that there's a bug somewhere in this that needs to get investigated / resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants