Skip to content

Commit

Permalink
Add timing for plugin loading
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Sep 17, 2014
1 parent 66e6820 commit 0181df5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import ConfigParser
import warnings
import codecs
import time

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

plugin_times = {}

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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down

3 comments on commit 0181df5

@3nids
Copy link
Member

@3nids 3nids commented on 0181df5 Sep 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

@3nids 3nids commented on 0181df5 Sep 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 9ebb69e

@NathanW2
Copy link
Member Author

@NathanW2 NathanW2 commented on 0181df5 Sep 17, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.