mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Add timing for plugin loading
This commit is contained in:
parent
66e6820ba1
commit
0181df5553
@ -39,6 +39,7 @@ import re
|
|||||||
import ConfigParser
|
import ConfigParser
|
||||||
import warnings
|
import warnings
|
||||||
import codecs
|
import codecs
|
||||||
|
import time
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# ERROR HANDLING
|
# ERROR HANDLING
|
||||||
@ -106,6 +107,8 @@ plugin_paths = []
|
|||||||
# dictionary of plugins
|
# dictionary of plugins
|
||||||
plugins = {}
|
plugins = {}
|
||||||
|
|
||||||
|
plugin_times = {}
|
||||||
|
|
||||||
# list of active (started) plugins
|
# list of active (started) plugins
|
||||||
active_plugins = []
|
active_plugins = []
|
||||||
|
|
||||||
@ -190,7 +193,7 @@ def loadPlugin(packageName):
|
|||||||
|
|
||||||
def startPlugin(packageName):
|
def startPlugin(packageName):
|
||||||
""" initialize the plugin """
|
""" initialize the plugin """
|
||||||
global plugins, active_plugins, iface
|
global plugins, active_plugins, iface, plugin_times
|
||||||
|
|
||||||
if packageName in active_plugins: return False
|
if packageName in active_plugins: return False
|
||||||
if packageName not in sys.modules: 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
|
errMsg = QCoreApplication.translate("Python", "Couldn't load plugin %s" ) % packageName
|
||||||
|
|
||||||
|
start = time.clock()
|
||||||
# create an instance of the plugin
|
# create an instance of the plugin
|
||||||
try:
|
try:
|
||||||
plugins[packageName] = package.classFactory(iface)
|
plugins[packageName] = package.classFactory(iface)
|
||||||
@ -220,6 +224,8 @@ def startPlugin(packageName):
|
|||||||
|
|
||||||
# add to active plugins
|
# add to active plugins
|
||||||
active_plugins.append(packageName)
|
active_plugins.append(packageName)
|
||||||
|
end = time.end()
|
||||||
|
plugin_times[packageName] = "{0:02f}s".format(end - start)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user