summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-03 07:44:45 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-11-03 07:44:45 -0400
commitcedd332fd80945d2fb42655a03feb47be6cbaa4c (patch)
tree23b7fd6c2e975d5715e71a42c971c99cfea5d5d9
parent311d16a4fe6274dedcf0ade8a68e1b010833a341 (diff)
downloadpython-coveragepy-git-cedd332fd80945d2fb42655a03feb47be6cbaa4c.tar.gz
debug(lab): remove opcode histogram from lab/parser.py
-rw-r--r--lab/parser.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/lab/parser.py b/lab/parser.py
index 4e11662b..bbf92508 100644
--- a/lab/parser.py
+++ b/lab/parser.py
@@ -17,8 +17,6 @@ import disgen
from coverage.parser import PythonParser
from coverage.python import get_python_source
-opcode_counts = collections.Counter()
-
class ParserMain:
"""A main for code parsing experiments."""
@@ -32,10 +30,6 @@ class ParserMain:
help="Disassemble"
)
parser.add_option(
- "-H", action="store_true", dest="histogram",
- help="Count occurrences of opcodes"
- )
- parser.add_option(
"-R", action="store_true", dest="recursive",
help="Recurse to find source files"
)
@@ -62,12 +56,6 @@ class ParserMain:
else:
self.one_file(options, args[0])
- if options.histogram:
- total = sum(opcode_counts.values())
- print(f"{total} total opcodes")
- for opcode, number in opcode_counts.most_common():
- print(f"{opcode:20s} {number:6d} {number/total:.1%}")
-
def one_file(self, options, filename):
"""Process just one file."""
# `filename` can have a line number suffix. In that case, extract those
@@ -93,7 +81,7 @@ class ParserMain:
if options.dis:
print("Main code:")
- self.disassemble(pyparser.byte_parser, histogram=options.histogram)
+ self.disassemble(pyparser.byte_parser)
arcs = pyparser.arcs()
@@ -132,7 +120,7 @@ class ParserMain:
print("%4d %s%s %s" % (lineno, "".join(marks), a, ltext))
- def disassemble(self, byte_parser, histogram=False):
+ def disassemble(self, byte_parser):
"""Disassemble code, for ad-hoc experimenting."""
for bp in byte_parser.child_parsers():
@@ -143,9 +131,6 @@ class ParserMain:
print("\n%s: " % bp.code)
upto = None
for disline in disgen.disgen(bp.code):
- if histogram:
- opcode_counts[disline.opcode] += 1
- continue
if disline.first:
if srclines:
upto = upto or disline.lineno-1