Mercurial > public > mercurial-scm > hg
comparison contrib/perf-utils/perf-revlog-write-plot.py @ 41190:c3e5ce3a9483
contrib: update window title when possible in perf-revlog-write-plot.py
This is useful when comparing multiple graphs.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 03 Jan 2019 22:13:28 +0100 |
parents | abd7b75e80bc |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
41189:99125b7fb93e | 41190:c3e5ce3a9483 |
---|---|
20 pyplot as plt, | 20 pyplot as plt, |
21 ticker as mticker, | 21 ticker as mticker, |
22 ) | 22 ) |
23 | 23 |
24 | 24 |
25 def plot(data): | 25 def plot(data, title=None): |
26 items = {} | 26 items = {} |
27 re_title = re.compile(r'^revisions #\d+ of \d+, rev (\d+)$') | 27 re_title = re.compile(r'^revisions #\d+ of \d+, rev (\d+)$') |
28 for item in data: | 28 for item in data: |
29 m = re_title.match(item['title']) | 29 m = re_title.match(item['title']) |
30 if m is None: | 30 if m is None: |
106 if visible: | 106 if visible: |
107 legline.set_alpha(1.0) | 107 legline.set_alpha(1.0) |
108 else: | 108 else: |
109 legline.set_alpha(0.2) | 109 legline.set_alpha(0.2) |
110 fig.canvas.draw() | 110 fig.canvas.draw() |
111 if title is not None: | |
112 fig.canvas.set_window_title(title) | |
111 fig.canvas.mpl_connect('pick_event', onpick) | 113 fig.canvas.mpl_connect('pick_event', onpick) |
112 | 114 |
113 plt.show() | 115 plt.show() |
114 | 116 |
115 | 117 |
117 import sys | 119 import sys |
118 | 120 |
119 if len(sys.argv) > 1: | 121 if len(sys.argv) > 1: |
120 print('reading from %r' % sys.argv[1]) | 122 print('reading from %r' % sys.argv[1]) |
121 with open(sys.argv[1], 'r') as fp: | 123 with open(sys.argv[1], 'r') as fp: |
122 plot(json.load(fp)) | 124 plot(json.load(fp), title=sys.argv[1]) |
123 else: | 125 else: |
124 print('reading from stdin') | 126 print('reading from stdin') |
125 plot(json.load(sys.stdin)) | 127 plot(json.load(sys.stdin)) |