]> thyrsus.com Git - comparator.git/commitdiff
Added statistics options.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 16 Sep 2003 09:04:10 +0000 (09:04 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 16 Sep 2003 09:04:10 +0000 (09:04 +0000)
filterator

index 1c5966f7b65a4ece46815f4b8bf7268ec76ebd96..aa8750a3d2f343c82fa87c17ca4d41c61e1a2b73 100755 (executable)
@@ -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)