[QGIS-Developer] Profiler?

Nyall Dawson nyall.dawson at gmail.com
Sun May 24 02:29:12 PDT 2020


On Sat, 23 May 2020 at 22:19, Nathan Woodrow <madmanwoo at gmail.com> wrote:
>
> Correct. QgsRuntimeProfiler is the tool that can do it.
>
> https://qgis.org/api/classQgsRuntimeProfiler.html
>
> In Python you can access it using this:
>
>  QgsApplication.instance().profiler()
>
> An example:
>
>    QgsApplication.instance().profiler().start("my_thing")
> # long expensive stuff
>      QgsApplication.instance().profiler().end()


Or the newer, more Pythonic  way:

   with QgsRuntimeProfiler.profile('loading something'):
      # do some stuff

I'd encourage plugin authors to use this in their plugins
initialisation code as much as makes sense!

Nyall

>
>
>
> On Sat, May 23, 2020 at 9:38 PM Richard Duivenvoorde <rdmailings at duif.net> wrote:
>>
>> On 5/23/20 11:42 AM, Sebastian M. Ernst wrote:
>>
>> > @Richard How does your Citrix setup / architecture look like
>> > (approximately)?
>>
>> I'll ask around for more details, as I'm there just as a user of that setup.
>>
>> But I did try a lot of things: and exactly what you tell: their virus
>> scanner was pushing some hash version of all python files to some online
>> service. So I disabled it...
>> But still... And off course they are working with some network shares,
>> so I will try out some of your other idea's
>>
>> > @Nathan & @Nyall Where in QGIS' source can I find the profiling tool? I
>> > just searched and could not locate it ... Would you consider adding
>> > support for a Python profiler to it, e.g. [1], [2] or [3]? The relevant
>> > code could (conditionally) be injected somewhere around here [4] or here
>> > [5]. I have played with this idea a while ago. It works in principle,
>> > but a proper integration into your GUI would be great ...
>>
>> In my debug build, using
>> export QGIS_DEBUG=5
>>
>> I see:
>>
>> ../src/core/symbology/qgssymbollayerutils.cpp:3936 :
>> (svgSymbolNameToPath) [0ms] Svg found in alternative path
>> ../src/core/qgsruntimeprofiler.cpp:80 : (end) [0ms] PROFILE: Load
>> default style database/Load symbols/topo camp - 0.001
>> ../src/core/qgsruntimeprofiler.cpp:80 : (end) [0ms] PROFILE: Load
>> default style database/Load symbols/topo foot - 0
>> ../src/core/qgsruntimeprofiler.cpp:80 : (end) [0ms] PROFILE: Load
>> default style database/Load symbols/topo forest - 0
>>
>> So:
>> https://github.com/qgis/QGIS/blob/master/src/core/qgsruntimeprofiler.cpp :-)
>>
>> Regards,
>>
>> Richard Duivenvoorde
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list