[Qgis-user] Measuring Map Rendering Time using PyQGIS
Alexandre Neto
senhor.neto at gmail.com
Mon Jun 26 04:01:36 PDT 2023
Hi,
I am looking for a way to audit a QGIS projects in terms of layer rendering
time.
I was able to measuring the rendering every time I refresh the the map
canvas, change layers or change extent, using the following code (inspired
by Anita code):
from datetime import datetime
def get_time():
t1 = datetime.now()
print('Rendering time:',t1-t0, 'seconds')
def reset_time():
global t0
t0 = datetime.now()
canvas = iface.mapCanvas()
canvas.mapCanvasRefreshed.connect(get_time)
canvas.extentsChanged.connect(reset_time)
canvas.layersChanged.connect(reset_time)
Now, I wanted to programmatically zoom in, zoom out, enable and disable
layers, etc... but If I give two or more of these commands together, each
command won't wait for the other to finish rendering, therefore I am unable
to measure the time.
For example:
iface.actionZoomFullExtent()
canvas.zoomByFactor(0.5)
Only returns the time for the last zoom to render.
I have tried using time.wait() but that stops the rendering all together.
Thanks,
Alexandre Neto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230626/843e5be5/attachment.htm>
More information about the QGIS-User
mailing list