Is it possible to measure when QGIS starts and stops loading/rendering a layer?

I used something similar in OpenLayers before (loadstart and loadend event, http://dev.openlayers.org/examples/layerLoadMonitoring.html) but haven't figured out yet how to do that in QGIS with PyQGIS.

I want to use it in order to measure which layers take long to load (geometry and attributes!).

I know that there is something that can be used outside of QGIS to benchmark loading times (https://github.com/DMS-Aus/qgis2img) but

  • the loading times of layers in QGIS were way longer than the values measured by the tool. I guess that tool doesn't read the attributes.
  • I would like to measure the loading times inside QGIS

I think that there has to be something that already listens to something like a loadstart and loadend signal as in the status bar there is an indicator that is shown until the layer is loaded completely:

enter image description here

  • Have you seen Settings > Options > Rendering > Debugging > Map canvas refresh? It measures the canvas refresh time which could also be an indirect method to measuring layer rendering.
    – Joseph
    Commented Jun 13, 2018 at 13:02
  • @Joseph: but this does not give me the ability to check the loading time for each layer seperately, does it?
    – Thomas B
    Commented Jun 13, 2018 at 13:13
  • Maybe if you have such a small project with small-size files, the timing might be close otherwise nope :). Perhaps you can set a timer for the QgsMapLayerRenderer class.
    – Joseph
    Commented Jun 13, 2018 at 13:22
  • I'm not sure why would you need this, but in QGIS the speed of your layer's load would depend on the speed of your hard drive, so measuring the speed of load is pretty much a measure of your hard-drive speed and not how long the QGIS takes to process it. I have noticed it when I moved all the content from Network Drive to a local SSD, and now all the layers that had noticeable load times (2-5 seconds+) started loading in <0.1 second.
    – Ruslan
    Commented Jun 13, 2018 at 22:02
  • @Joseph: The QGIS-projects for which i want to find the bottlenegs have between 100 and 150 layers each
    – Thomas B
    Commented Jun 14, 2018 at 5:14

2 Answers 2


Go to settings > options > rendering, enable debug map canvas refresh, have a look at the message log. Done.

enter image description here

enter image description here

  • 1
    But this gives me very 'fragmented' measurings. Following Screenshot shows a part of the log from when I opened a project. The same layer occurs nearly 20 times with different partial loading times of the overall loading time: i.sstatic.net/SgVTR.png . Havin projects with more than 100 layers I think this way I couldn't figure out the bottleneg. Is there any chance to measure the total loading times for each layer with pyqgis or if not would this be hard to implement?
    – Thomas B
    Commented Jun 18, 2018 at 5:34
  • 2
    The times are a complex construct anyway, local caches may deliver results on subsequent loads, do incremental rendering of tiles (e.g. WMTS, YXZ), network load, cpu availability, disk access, indexes, ... have a strong influence. You might be able to trigger your own rendering job and watch for signals for individual layers. But I think it's easier to just parse these lines, which are written based on renderingTime. Commented Jun 18, 2018 at 13:41

What about this:

def start_signal():
    print "started: {0}".format(datetime.datetime.now())

def stop_signal():
    print "finished: {0}".format(datetime.datetime.now())


layer = QgsRasterLayer('A:\Temp\dop_test.tif', 'test_layer')

That results in:

<qgis._core.QgsRasterLayer object at 0x0000000023B49950>
started: 2018-06-15 10:37:44.438000
finished: 2018-06-15 10:37:44.553000

Unfortunately, it's less like a monitor - because it's necessary to load the layers via Python. It's not working if you are loading a project, because there is no information about the "current layer" in the connected signals.

  • Good to know how to measure single layers but I need to check the loading times for whole projects and for different Zoomlevels/extents
    – Thomas B
    Commented Jun 15, 2018 at 12:45
  • Actually it also works for a project if you add the signal&slot connection into the python console. And it also works for zoomlevels.
    – aleho
    Commented Jun 15, 2018 at 12:59
  • but it measures the total rendering time for all layers. So it doesn't determine which layer takes longest to load
    – Thomas B
    Commented Jun 16, 2018 at 4:29
  • No, you would need to add every layer into a python script for that. Then it would print after every layer.
    – aleho
    Commented Jun 18, 2018 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.