Author: Remi Meier <[email protected]>
Branch: stmgc-c7
Changeset: r74590:5e380588d479
Date: 2014-11-19 09:56 +0100
http://bitbucket.org/pypy/pypy/changeset/5e380588d479/

Log:    attach clickable info to plot elements

diff --git a/pypy/stm/plot_stm_log.py b/pypy/stm/plot_stm_log.py
--- a/pypy/stm/plot_stm_log.py
+++ b/pypy/stm/plot_stm_log.py
@@ -68,6 +68,7 @@
         self.stop_time = 0
         self.aborted = False
         self.pauses = []
+        self.info = []
 
 
 def plot_log(logentries, ax):
@@ -106,6 +107,17 @@
                 tr.pauses[-1] = (tr.pauses[-1][0], entry.timestamp)
 
 
+        # attach logentry as transaction info
+        tr = curr_trs.get(th_num)
+        if tr is not None:
+            tr.info.append(str(entry))
+        if entry.event in (psl.STM_ABORTING_OTHER_CONTENTION,):
+            tr2 = curr_trs.get(entry.otherthreadnum)
+            if tr2 is not None:
+                tr2.info.append(str(entry))
+
+
+
     # plt.ion()
     for th_num, trs in finished_trs.items():
         # plt.draw()
@@ -118,7 +130,8 @@
         for tr in trs:
             add_transaction(boxes, hlines,
                             tr.start_time, None, tr.stop_time,
-                            tr.aborted, tr.pauses)
+                            tr.aborted, tr.pauses,
+                            "\n".join(tr.info))
         plot_boxes(boxes, th_num, ax)
         plot_hlines(hlines, th_num, ax)
         print "> Pauses:", len(hlines)
@@ -159,7 +172,7 @@
     axs[0].set_ylabel("Thread")
     axs[0].set_ylim(0, thread_count)
     axs[0].set_yticks([r+0.5 for r in range(thread_count)])
-    axs[0].set_yticklabels(range(1, thread_count+1))
+    axs[0].set_yticklabels(range(thread_count))
     #axs[0].set_xticks([])
     print "Drawn."
 
diff --git a/pypy/stm/print_stm_log.py b/pypy/stm/print_stm_log.py
--- a/pypy/stm/print_stm_log.py
+++ b/pypy/stm/print_stm_log.py
@@ -51,6 +51,16 @@
         self.marker1 = marker1
         self.marker2 = marker2
 
+    def __str__(self):
+        s = '[%.3f][%s->%s]\t%s' % (
+            self.timestamp, self.threadnum, self.otherthreadnum,
+            event_name[self.event])
+        if self.marker1:
+            s += ':\n%s' % print_marker(self.marker1)
+        if self.marker2:
+            s += '\n%s' % print_marker(self.marker2)
+        return s
+
 
 def parse_log(filename):
     f = open(filename, 'rb')
@@ -131,17 +141,28 @@
     def sortkey(self):
         return self.aborted_time + self.paused_time
 
+    def __str__(self):
+        s = '%.3fs lost in aborts, %.3fs paused (%dx %s)\n' % (
+            self.aborted_time, self.paused_time, self.num_events, 
event_name[self.event])
+        s += print_marker(self.marker1)
+        if self.marker2:
+            s += '\n%s' % print_marker(self.marker2)
+        return s
+
+
+
 
 r_marker = re.compile(r'File "(.+)", line (\d+)')
 
 def print_marker(marker):
-    print '  ' + marker
+    s = '  %s' % marker
     match = r_marker.match(marker)
     if match:
         line = linecache.getline(match.group(1), int(match.group(2)))
         line = line.strip()
         if line:
-            print '    ' + line
+            s += '\n    %s' % line
+    return s
 
 def percent(fraction, total):
     r = '%.1f' % (fraction * 100.0 / total)
@@ -210,11 +231,7 @@
             idx = int((t - start_time) / total_time * intervals)
             timeline[idx] += 1
 
-        print '%.3fs lost in aborts, %.3fs paused (%dx %s)' % (
-            c.aborted_time, c.paused_time, c.num_events, event_name[c.event])
-        print_marker(c.marker1)
-        if c.marker2:
-            print_marker(c.marker2)
+        print str(c)
         print "time line:", "".join(['x' if i else '.' for i in timeline])
         print
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to