Commit 266ebdac authored by Guido van Rossum's avatar Guido van Rossum

(Apologies to Jeremy. One 'h' is enough in the getopt argument list. :-)

Sort options alphabetically.  Remove dependency between -S, -q and -v
options (-S no longer disables -q and enables -v).  Remove dependency
between -S and -h (histogram is printed regardless of dostats).
parent 6c2d38e1
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
############################################################################## ##############################################################################
"""Trace file statistics analyzer. """Trace file statistics analyzer.
Usage: stats.py [-h] [-i interval] [-q] [-v] [-S] tracefile Usage: stats.py [-h] [-i interval] [-q] [-S] [-v] tracefile
-h: print histogram -h: print histogram
-i: summarizing interval in minutes (default 15; max 60) -i: summarizing interval in minutes (default 15; max 60)
-q: quiet; don't print sommaries -q: quiet; don't print summaries
-S: don't print statistics
-v: verbose; print each record -v: verbose; print each record
-S: don't print statistics (turns off -q)
""" """
"""File format: """File format:
...@@ -66,11 +66,13 @@ def main(): ...@@ -66,11 +66,13 @@ def main():
print_histogram = 0 print_histogram = 0
interval = 900 # Every 15 minutes interval = 900 # Every 15 minutes
try: try:
opts, args = getopt.getopt(sys.argv[1:], "hi:qvSh") opts, args = getopt.getopt(sys.argv[1:], "hi:qSv")
except getopt.error, msg: except getopt.error, msg:
usage(msg) usage(msg)
return 2 return 2
for o, a in opts: for o, a in opts:
if o == '-h':
print_histogram = 1
if o == "-i": if o == "-i":
interval = int(60 * float(a)) interval = int(60 * float(a))
if interval <= 0: if interval <= 0:
...@@ -80,14 +82,10 @@ def main(): ...@@ -80,14 +82,10 @@ def main():
if o == "-q": if o == "-q":
quiet = 1 quiet = 1
verbose = 0 verbose = 0
if o == "-v":
verbose = 1
if o == "-S": if o == "-S":
dostats = 0 dostats = 0
if o == "-v":
verbose = 1 verbose = 1
quiet = 0
if o == '-h':
print_histogram = 1
if len(args) != 1: if len(args) != 1:
usage("exactly one file argument required") usage("exactly one file argument required")
return 2 return 2
...@@ -225,6 +223,8 @@ def main(): ...@@ -225,6 +223,8 @@ def main():
addcommas(bycode.get(code, 0)), addcommas(bycode.get(code, 0)),
code, code,
explain.get(code) or "*** unknown code ***") explain.get(code) or "*** unknown code ***")
# Print histogram
if print_histogram: if print_histogram:
print print
print "Histogram of object load frequency" print "Histogram of object load frequency"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment