Skip to content

PERF: speed up MPLPlot._apply_axis_properties by skipping expensive tick enumeration where feasible #25665

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 1 commit into from
Mar 15, 2019

Conversation

qwhelan
Copy link
Contributor

@qwhelan qwhelan commented Mar 11, 2019

This issue likely originates in matplotlib, as it seems enumeration of axis.majorTicks frequently requires re-creating all of the ticks. We sidestep that here by only enumerating the labels if we will mutate them; in particular, this is beneficial to MPLPlot._post_plot_logic_common().

asv compare upstream/master HEAD -s --sort ratio

Benchmarks that have improved:

       before           after         ratio
     [63755498]       [eb051291]
     <plot_perf~1>       <plot_perf>
-      67.0±0.8ms       57.4±0.4ms     0.86  plotting.FramePlotting.time_frame_plot('hexbin')
-        61.1±2ms       50.3±0.7ms     0.82  plotting.FramePlotting.time_frame_plot('scatter')
-      48.3±0.2ms       39.6±0.2ms     0.82  plotting.TimeseriesPlotting.time_plot_regular_compat
-        52.3±2ms       42.2±0.4ms     0.81  plotting.TimeseriesPlotting.time_plot_irregular

Benchmarks that have stayed the same:

       before           after         ratio
     [63755498]       [eb051291]
     <plot_perf~1>       <plot_perf>
          171±4ms          175±5ms     1.02  plotting.SeriesPlotting.time_series_plot('hist')
       92.9±0.2ms       94.1±0.2ms     1.01  plotting.SeriesPlotting.time_series_plot('pie')
        143±0.2ms        144±0.2ms     1.01  plotting.FramePlotting.time_frame_plot('pie')
          851±6ms          844±6ms     0.99  plotting.FramePlotting.time_frame_plot('kde')
       1.97±0.02s       1.94±0.01s     0.99  plotting.TimeseriesPlotting.time_plot_table
        1.20±0.1s        1.18±0.1s     0.99  plotting.Misc.time_plot_andrews_curves
         80.1±5ms         78.7±6ms     0.98  plotting.SeriesPlotting.time_series_plot('line')
         736±10ms         723±10ms     0.98  plotting.SeriesPlotting.time_series_plot('kde')
        193±0.2ms          190±1ms     0.98  plotting.FramePlotting.time_frame_plot('barh')
       87.6±0.3ms       85.7±0.3ms     0.98  plotting.SeriesPlotting.time_series_plot('bar')
          208±5ms          203±3ms     0.98  plotting.FramePlotting.time_frame_plot('area')
       87.5±0.4ms       85.5±0.6ms     0.98  plotting.SeriesPlotting.time_series_plot('barh')
          199±5ms          192±2ms     0.96  plotting.SeriesPlotting.time_series_plot('area')
        196±0.8ms        189±0.4ms     0.96  plotting.FramePlotting.time_frame_plot('bar')
       91.3±0.4ms        86.9±10ms     0.95  plotting.FramePlotting.time_frame_plot('line')
          201±2ms          191±3ms     0.95  plotting.FramePlotting.time_frame_plot('hist')
       83.5±0.2ms         76.7±1ms     0.92  plotting.TimeseriesPlotting.time_plot_regular

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@codecov
Copy link

codecov bot commented Mar 11, 2019

Codecov Report

Merging #25665 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25665      +/-   ##
==========================================
+ Coverage   91.24%   91.24%   +<.01%     
==========================================
  Files         172      172              
  Lines       52967    52968       +1     
==========================================
+ Hits        48332    48333       +1     
  Misses       4635     4635
Flag Coverage Δ
#multiple 89.82% <100%> (ø) ⬆️
#single 41.74% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/plotting/_core.py 83.55% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1017382...5962817. Read the comment docs.

@WillAyd WillAyd added the Performance Memory or execution speed performance label Mar 11, 2019
@jreback jreback added this to the 0.25.0 milestone Mar 13, 2019
@TomAugspurger
Copy link
Contributor

Thanks @qwhelan!

@TomAugspurger TomAugspurger merged commit 01d3dc2 into pandas-dev:master Mar 15, 2019
@qwhelan qwhelan deleted the plot_perf branch March 15, 2019 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants