From ce666adfb14182dbdc0e848c6b5a60ceae4fb50c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 16 Sep 2003 09:04:10 +0000 Subject: [PATCH] Added statistics options. --- filterator | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/filterator b/filterator index 1c5966f..aa8750a 100755 --- a/filterator +++ b/filterator @@ -216,11 +216,11 @@ def report_common(state, stats=1,list=1): if __name__ == '__main__': try: - (optlist, args) = getopt.getopt(sys.argv[1:], 'd:ns:x') + (optlist, args) = getopt.getopt(sys.argv[1:], 'd:ns:Sx') except getopt.GetoptError: sys.stderr.write("usage: filterator [-d dir] [-n] [-s size] [-x]\n") sys.exit(2) - nofilter = debug = 0 + stats = nofilter = debug = 0 minsize = 5 linecounts = {} for (opt, val) in optlist: @@ -230,6 +230,8 @@ if __name__ == '__main__': nofilter = 1 elif opt == '-s': minsize = int(val) + elif opt == '-S': + stats = 1 elif opt == '-x': debug = 1 @@ -237,4 +239,10 @@ if __name__ == '__main__': if minsize: state.filter_by_size(minsize) - report_common(state) + if stats: + print "%d overlaps" % state.segment_count() + for (tree, totallines) in state.trees.items(): + lines = state.line_count(tree) + print "%s:%d:%d" % (tree, lines, state.trees[tree]) + else: + report_common(state) -- 2.43.0