cProfiling hvPlot+Bokeh vs GeoViews+datashader+Bokeh: puzzling results

Hi there,

I’m currently comparing, among others, different geospatial plotting interfaces including hvPlot and Geoviews+datashader for a thesis. One part is comparing the total CPU runtimes of each library to generate the same map product, using the same data. The performance benchmarking is done with cProfile. The results are a bit puzzling


By this measure, hvPlot without datashader even outperforms GeoViews+datashader which doesn’t seem right to me. The hvPlot and GeoViews+datashader implementations are structurally identical, but for hvPlot the cProfiles are being created almost immediately (a print statement confirms the dump to .prof, followed by hvPlot's “Launching server at …”), and thus before the browser window is opened (I unfortunatel have to use hvplot.show(plot) as VSCode-Python won’t automatically show the figure in the interactive interpreter if just callling plot by itself) and the actual rendering is finished in-browser much later (we’re talking 144,000 partially very elaborate polygons). The outputs for GeoViews and Geoviews+datashader simply appear in the VSCode-Interpreter once the layout is defined but I haven’t figured out how to do this with hvPlot. That would obviously increase comparability of the results.

So what do you think could be happening here?

I presume it has somethnig to do with how hvPlot hands over the geometries to Bokeh and when cProfile thus thinks the function is ‘done’ even though the main rendering in-browser is yet to complete. Is there any way to also catch that ‘actual’ rendering as part of a cProfile or at least make hvPlot render the figure in VSCode-Python which may be all it takes to make the results comparable?

The basic setup is this: I’m wrapping the plot definition in a function called renderFigure() which is then wrapped with a decorator that basically does this:

p = cProfile.Profile() 
p.enable() # start cProfiling

value = func(*args, **kwargs) # execute renderFigure()

p.disable() # stop cProfiling
p.dump_stats() # write cProfile to file

Thanks a million.