History

perf, sched migration: Make it vertically scrollable

With scheduler traces covering more than two cpus, rectangles of the CPUs 3 and more are not visibles. This makes the vertical navigation scrollable so that all of the CPUs rectangles are available. We also want to be able to zoom vertically, so that we can fit at best the screen with CPU rectangles, but that's for later.

Frederic Weisbecker committed 16 years ago

Commit 70d815a1 parent 0cddf561 file · +20 −9Browse files

Showing the changes to tools/perf/scripts/python (1 of 1 file). Show all

Unified · Split

tools/perf/scripts/python/sched-migration.py+20−9
@@ -43,18 +43,20 @@ class RootFrame(wx.Frame): · 42 unmodified lines
4343 self.timeslices = timeslices
4444 (self.ts_start, self.ts_end) = timeslices.interval()
4545 self.update_width_virtual()
46+ self.nr_cpus = timeslices.max_cpu() + 1
47+ self.height_virtual = RootFrame.Y_OFFSET + (self.nr_cpus * (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE))
4648
4749 # whole window panel
4850 self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height))
4951
5052 # scrollable container
5153 self.scroll = wx.ScrolledWindow(self.panel)
52− self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, 100 / 10)
54+ self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale)
5355 self.scroll.EnableScrolling(True, True)
5456 self.scroll.SetFocus()
5557
5658 # scrollable drawing area
57− self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width, self.screen_height / 2))
59+ self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width - 15, self.screen_height / 2))
5860 self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint)
5961 self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
6062 self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)
@@ -65,9 +67,8 @@ class RootFrame(wx.Frame): · 4 unmodified lines
6567 self.scroll.Fit()
6668 self.Fit()
6769
68− self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, -1, wx.SIZE_USE_EXISTING)
70+ self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, self.height_virtual, wx.SIZE_USE_EXISTING)
6971
70− self.max_cpu = -1
7172 self.txt = None
7273
7374 self.Show(True)
@@ -143,8 +144,6 @@ class RootFrame(wx.Frame): · 69 unmodified lines
143144
144145 for cpu in timeslice.rqs:
145146 self.update_rectangle_cpu(dc, timeslice, cpu, self.timeslices[0].start)
146− if cpu > self.max_cpu:
147− self.max_cpu = cpu
148147
149148 def on_paint(self, event):
150149 color = wx.Colour(0xff, 0xff, 0xff)
@@ -163,7 +162,7 @@ class RootFrame(wx.Frame): · 12 unmodified lines
163162 cpu = y / (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
164163 height = y % (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
165164
166− if cpu < 0 or cpu > self.max_cpu or height > RootFrame.CPU_HEIGHT:
165+ if cpu < 0 or cpu > self.nr_cpus - 1 or height > RootFrame.CPU_HEIGHT:
167166 return -1
168167
169168 return cpu
@@ -206,7 +205,7 @@ class RootFrame(wx.Frame): · 36 unmodified lines
206205 self.update_width_virtual()
207206 (xpos, ypos) = self.scroll.GetViewStart()
208207 xpos = self.us_to_px(x) / self.scroll_scale
209− self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, 100 / 10, xpos, ypos)
208+ self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale, xpos, ypos)
210209 self.Refresh()
211210
212211 def zoom_in(self):
@@ -234,7 +233,11 @@ class RootFrame(wx.Frame): · 21 unmodified lines
234233 if key == wx.WXK_RIGHT:
235234 self.scroll.Scroll(x + 1, y)
236235 elif key == wx.WXK_LEFT:
237− self.scroll.Scroll(x -1, y)
236+ self.scroll.Scroll(x - 1, y)
237+ elif key == wx.WXK_DOWN:
238+ self.scroll.Scroll(x, y + 1)
239+ elif key == wx.WXK_UP:
240+ self.scroll.Scroll(x, y - 1)
238241
239242
240243 threads = { 0 : "idle"}
@@ -504,6 +507,14 @@ class TimeSliceList(UserList): · 263 unmodified lines
504507
505508 return (self.data[0].start, self.data[-1].end)
506509
510+ def max_cpu(self):
511+ last_ts = self.data[-1]
512+ max_cpu = 0
513+ for cpu in last_ts.rqs:
514+ if cpu > max_cpu:
515+ max_cpu = cpu
516+ return max_cpu
517+
507518
508519 class SchedEventProxy:
509520 def __init__(self):