Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prf mouse move hitlist #4813

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

Merged
merged 2 commits into from
Jul 30, 2015

Conversation

tacaswell
Copy link
Member

This address some of #4767.

The issue in 604299f is that np.MachAr(float).xmin takes ~8-10 ms and gets 2x in the hitlist code path. Moving this to a constant at the top is a major speed up and for a blank figure gets the hitlist run time down to 5-6ms from a bit over 20ms (on the computer I was testing on).

There is still an issue that sorting out if the cursor hits a Line2D artist takes at least 1ms so if you have 300 lines, it takes a third of a second for the callback to run.

Long term, we should look into making this code faster by making contains run faster (a lot of time is spent in https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/lines.py#L36), by finding a way to cache this in a smart way but in the short term I think we need to add a per-axes way of turning this off and probably default to off.

attn @blink1073 @mdboom @pwuertz

Looking up MachAr was taking about 10ms which is way to slow to be
inside of the mouse motion event loop.

We are using it to get a constant so we can look it up and compute
the constant once at the top.
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jul 28, 2015
@tacaswell tacaswell added this to the next point release milestone Jul 28, 2015
@tacaswell
Copy link
Member Author

@joferkington Do you work around this sort of thing in mpldatacursor?

@blink1073
Copy link
Member

@tacaswell, I profiled a plot with 10000 random segments, and the contains method was taking <0.5ms.

@blink1073
Copy link
Member

Granted, it was a single Line2D object...

@blink1073
Copy link
Member

Otherwise, I agree that an artist should be able to opt out of mouse-move hit testing.

@jenshnielsen
Copy link
Member

This is a significant when testing on a plot with 100 lines. We might need to do more however I don't see any reason to hold this back

jenshnielsen added a commit that referenced this pull request Jul 30, 2015
@jenshnielsen jenshnielsen merged commit 8b6ee19 into matplotlib:master Jul 30, 2015
@tacaswell tacaswell deleted the prf_mouse_move_hitlist branch July 30, 2015 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants