Use cProfile for profiling. Don't print user-visible help for profiling.

This commit is contained in:
Bastian Kleineidam 2012-08-09 12:38:06 +02:00
parent 64d011316a
commit 898c426d7a
5 changed files with 626 additions and 1122 deletions

1380
doc/de.po

File diff suppressed because it is too large Load diff

View file

@ -146,10 +146,6 @@ lokalen Spracheinstellung. Gültige Enkodierungen sind unter
\fBhttp://docs.python.org/library/\:codecs.html#standard\-encodings\fP
aufgelistet.
.TP
\fB\-\-profile\fP
Schreibe Profiling\-Daten in eine Datei namens \fBlinkchecker.prof\fP im
aktuellen Arbeitsverzeichnis. Siehe auch \fB\-\-viewprof\fP.
.TP
\fB\-q\fP, \fB\-\-quiet\fP
Keine Ausgabe, ein Alias für \fB\-o none\fP. Dies ist nur in Verbindung mit
\fB\-F\fP nützlich.
@ -164,9 +160,6 @@ Trace\-Information ausgeben.
Gebe alle geprüften URLs einmal aus. Standard ist es, nur fehlerhafte URLs
und Warnungen auszugeben.
.TP
\fB\-\-viewprof\fP
Gebe vorher generierte Profiling\-Daten aus. Siehe auch \fB\-\-profile\fP.
.TP
\fB\-W\fP\fIREGEX\fP, \fB\-\-warning\-regex=\fP\fIREGEX\fP
Definieren Sie einen regulären Ausdruck der eine Warnung ausgibt falls er
auf den Inhalt einer geprüften URL zutrifft. Dies gilt nur für gültige

View file

@ -136,10 +136,6 @@ The \fIENCODING\fP specifies the output encoding, the default is
that of your locale. Valid encodings are listed at
\fBhttp://docs.python.org/library/\:codecs.html#standard-encodings\fP.
.TP
\fB\-\-profile\fP
Write profiling data into a file named \fBlinkchecker.prof\fP
in the current working directory. See also \fB\-\-viewprof\fP.
.TP
\fB\-q\fP, \fB\-\-quiet\fP
Quiet operation, an alias for \fB\-o none\fP.
This is only useful with \fB\-F\fP.
@ -153,10 +149,6 @@ Print tracing information.
\fB\-v\fP, \fB\-\-verbose\fP
Log all checked URLs once. Default is to log only errors and warnings.
.TP
\fB\-\-viewprof\fP
Print out previously generated profiling data. See also
\fB\-\-profile\fP.
.TP
\fB\-W\fP\fIREGEX\fP, \fB\-\-warning\-regex=\fIREGEX\fP
Define a regular expression which prints a warning if it matches any
content of the checked link.

File diff suppressed because it is too large Load diff

View file

@ -44,7 +44,7 @@ import linkcheck.ansicolor
from linkcheck.director import console, check_urls, get_aggregate
# optional modules
has_optcomplete = linkcheck.fileutil.has_module("optcomplete")
has_profile = linkcheck.fileutil.has_module("profile")
has_profile = linkcheck.fileutil.has_module("cProfile")
has_pstats = linkcheck.fileutil.has_module("pstats")
has_meliae = linkcheck.fileutil.has_module("meliae")
@ -329,9 +329,7 @@ Valid encodings are listed at """ \
"""http://docs.python.org/lib/standard-encodings.html.""") % \
{'loggertypes': linkcheck.logger.LoggerKeys})
group.add_option("--profile", action="store_true", dest="profile",
help=_(
"""Write profiling data into a file named %s in the
current working directory. See also --viewprof.""") % _profile)
help=optparse.SUPPRESS_HELP)
group.add_option("-q", "--quiet", action="store_true", dest="quiet",
help=_(
"""Quiet operation, an alias for '-o none'.
@ -345,8 +343,7 @@ group.add_option("-v", "--verbose", action="store_true", dest="verbose",
help=_(
"""Log all URLs. Default is to log only errors and warnings."""))
group.add_option("--viewprof", action="store_true", dest="viewprof",
help=_(
"""Print out previously generated profiling data. See also --profile."""))
help=optparse.SUPPRESS_HELP)
group.add_option("-W", "--warning-regex", type="string", dest="warningregex",
metavar="REGEX",
help=_(
@ -692,14 +689,14 @@ Press Ctrl-C to cancel, RETURN to continue.""") % {"file": _profile}
sys.exit(1)
else:
log.warn(LOG_CMDLINE,
_("The `profile' Python module is not installed,"
_("The `cProfile' Python module is not installed,"
" therefore the --profile option is disabled."))
do_profile = False
# finally, start checking
if do_profile:
import profile
profile.run("check_urls(aggregate)", _profile)
import cProfile
cProfile.run("check_urls(aggregate)", _profile)
else:
check_urls(aggregate)
if config["debugmemory"]: