Author: andar
Revision: 5319
Log:
Add support to profile the daemon using the --profile option
Diff:
Modified: trunk/deluge/main.py
===================================================================
--- trunk/deluge/main.py 2009-05-28 10:37:09 UTC (rev 5318)
+++ trunk/deluge/main.py 2009-05-28 18:28:33 UTC (rev 5319)
@@ -143,6 +143,8 @@
help="Set the log level: none, info, warning, error, critical, debug",
action="store", type="str")
parser.add_option("-q", "--quiet", dest="quiet",
help="Sets the log level to 'none', this is the same as `-L none`",
action="store_true", default=False)
+ parser.add_option("--profile", dest="profile", action="store_true",
default=False,
+ help="Profiles the daemon" )
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
@@ -189,6 +191,10 @@
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile)
from deluge.log import LOG as log
+ if options.profile:
+ import hotshot
+ hsp =
hotshot.Profile(deluge.configmanager.get_config_dir("deluged.profile"))
+ hsp.start()
try:
from deluge.core.daemon import Daemon
Daemon(options, args)
@@ -200,3 +206,12 @@
except Exception, e:
log.exception(e)
sys.exit(1)
+ finally:
+ if options.profile:
+ hsp.stop()
+ hsp.close()
+ import hotshot.stats
+ stats =
hotshot.stats.load(deluge.configmanager.get_config_dir("deluged.profile"))
+ stats.strip_dirs()
+ stats.sort_stats("time", "calls")
+ stats.print_stats(400)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---