-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Is it possible to improve the performance of line()? #456
Comments
I just looked at the source code and see line uses |
Joseph or Greg had some ideas about how to speed it up, but fundamentally
lines should always be slower than points because points just increments
one bin, while line needs to solve the equation for a line and increment
every point along the way.
|
Yes, I guess the title should have been more like, 'Is line the expected amount slower than points?', or maybe, 'Can line be made faster?'. |
My immediate suggestions for performance gains are:
We currently use the more general algorithm that supports both ints and floats. However, by the time we need to draw a line, the points have been mapped to an integer space so float support is redundant.
We currently use Cohen-Sutherland for clipping a line to a bounding box, but the Liang-Barsky algorithm is considered significantly more efficient. |
I'd be very happy to try both suggestions; we're using line a lot in some performance-critical applications, so anything will help... |
I switched from Cohen-Sutherland to Liang-Barsky. The performance gains for random lines range from 50-75% improvement for a million lines. Related to #456
Switched from Cohen-Sutherland to Liang-Barsky. The performance gains for random lines range from 50-75% improvement for a million lines. Related to #456.
It would be nice to re-run those benchmarks now that #495 has been merged. |
Switched from Cohen-Sutherland to Liang-Barsky. The performance gains for random lines range from 50-75% improvement for a million lines. Related to #456.
I started with examples/timeseries.ipynb, modifying to have only one column:
In a bit of an ugly process, I then time
canvas.line()
andcanvas.points()
for increasing repeats of the dataframe:line seems to be a lot slower than points:
(Sorry for the screenshots, but github doesn't seem to allow notebooks to be attached.)
The text was updated successfully, but these errors were encountered: