Commits

Remi Meier committed 9e0e31a

stm: allow thread selection in plot_log

Comments (0)

Files changed (1)

pypy/tool/plot_log.py

             print "== pick ==\nCould not find info"
 
 
+def select_threads(logs, selection):
+    result = {}
+    renumber = 0
+    try:
+        for selects in selection:
+            if len(selects) == 1:
+                tid = selects[0]
+                result[renumber] = logs[tid]
+                renumber += 1
+            else:
+                lower, upper = selects
+                for tid in xrange(lower, upper+1):
+                    result[renumber] = logs[tid]
+                    renumber += 1
+    except KeyError:
+        print "Couldn't find", tid, "in", logs.keys(), ". Abort."
+        import sys
+        sys.exit()
+        
+    return result
+
 
 ############## MAIN ################
 
     logs = parse(args.file)
     print "Parsed."
 
+    if args.threads:
+        print "Select threads", args.threads
+        logs = select_threads(
+            logs, [map(int, x.split('-')) for x in args.threads.split(',')])
+
     print "Draw..."
     fig = plt.figure()
 
     parser.add_argument('--no-rma', action='store_const',
                         const=True, default=False,
                         help='do not draw the RMA plot')
-
+    parser.add_argument('--threads', help='thread selection 0-2,4')
 
     args = parser.parse_args()