Skip to content
Permalink
Browse files

Add timing for plugin loading

  • Loading branch information
NathanW2 committed Sep 17, 2014
1 parent 66e6820 commit 0181df555378eabbf58a29b76e687c54178ca5f1
Showing with 7 additions and 1 deletion.
  1. +7 −1 python/utils.py
@@ -39,6 +39,7 @@
import ConfigParser
import warnings
import codecs
import time

#######################
# ERROR HANDLING
@@ -106,6 +107,8 @@ def initInterface(pointer):
# dictionary of plugins
plugins = {}

plugin_times = {}

# list of active (started) plugins
active_plugins = []

@@ -190,7 +193,7 @@ def loadPlugin(packageName):

def startPlugin(packageName):
""" initialize the plugin """
global plugins, active_plugins, iface
global plugins, active_plugins, iface, plugin_times

if packageName in active_plugins: return False
if packageName not in sys.modules: return False
@@ -199,6 +202,7 @@ def startPlugin(packageName):

errMsg = QCoreApplication.translate("Python", "Couldn't load plugin %s" ) % packageName

start = time.clock()
# create an instance of the plugin
try:
plugins[packageName] = package.classFactory(iface)
@@ -220,6 +224,8 @@ def startPlugin(packageName):

# add to active plugins
active_plugins.append(packageName)
end = time.end()
plugin_times[packageName] = "{0:02f}s".format(end - start)

return True

3 comments on commit 0181df5

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Sep 17, 2014

I am getting this error when launching QGIS:
Traceback (most recent call last):
File "", line 1, in
File "/home/denis/opt/build-QGIS-qt4-Default/output/python/qgis/utils.py", line 227, in startPlugin
end = time.end()
AttributeError: 'module' object has no attribute 'end'

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Sep 17, 2014

fixed in 9ebb69e

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Sep 17, 2014

Please sign in to comment.
You can’t perform that action at this time.