contrib: update window title when possible in perf-revlog-write-plot.py
authorBoris Feld <boris.feld@octobus.net>
Thu, 03 Jan 2019 22:13:28 +0100
changeset 41190 c3e5ce3a9483
parent 41189 99125b7fb93e
child 41191 93c2beb9047f
contrib: update window title when possible in perf-revlog-write-plot.py This is useful when comparing multiple graphs.
contrib/perf-utils/perf-revlog-write-plot.py
--- a/contrib/perf-utils/perf-revlog-write-plot.py	Fri Jan 11 12:40:16 2019 -0800
+++ b/contrib/perf-utils/perf-revlog-write-plot.py	Thu Jan 03 22:13:28 2019 +0100
@@ -22,7 +22,7 @@
 )
 
 
-def plot(data):
+def plot(data, title=None):
     items = {}
     re_title = re.compile(r'^revisions #\d+ of \d+, rev (\d+)$')
     for item in data:
@@ -108,6 +108,8 @@
         else:
             legline.set_alpha(0.2)
         fig.canvas.draw()
+    if title is not None:
+        fig.canvas.set_window_title(title)
     fig.canvas.mpl_connect('pick_event', onpick)
 
     plt.show()
@@ -119,7 +121,7 @@
     if len(sys.argv) > 1:
         print('reading from %r' % sys.argv[1])
         with open(sys.argv[1], 'r') as fp:
-            plot(json.load(fp))
+            plot(json.load(fp), title=sys.argv[1])
     else:
         print('reading from stdin')
         plot(json.load(sys.stdin))