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
43 self.timeslices = timeslices43 self.timeslices = timeslices
44 (self.ts_start, self.ts_end) = timeslices.interval()44 (self.ts_start, self.ts_end) = timeslices.interval()
45 self.update_width_virtual()45 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))
46 48
47 # whole window panel49 # whole window panel
48 self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height))50 self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height))
49 51
50 # scrollable container52 # scrollable container
51 self.scroll = wx.ScrolledWindow(self.panel)53 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)
53 self.scroll.EnableScrolling(True, True)55 self.scroll.EnableScrolling(True, True)
54 self.scroll.SetFocus()56 self.scroll.SetFocus()
55 57
56 # scrollable drawing area58 # 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))
58 self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint)60 self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint)
59 self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)61 self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
60 self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)62 self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)
@@ -65,9 +67,8 @@ class RootFrame(wx.Frame): · 4 unmodified lines
65 self.scroll.Fit()67 self.scroll.Fit()
66 self.Fit()68 self.Fit()
67 69
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)
69 71
70 self.max_cpu = -1
71 self.txt = None72 self.txt = None
72 73
73 self.Show(True)74 self.Show(True)
@@ -143,8 +144,6 @@ class RootFrame(wx.Frame): · 69 unmodified lines
143 144
144 for cpu in timeslice.rqs:145 for cpu in timeslice.rqs:
145 self.update_rectangle_cpu(dc, timeslice, cpu, self.timeslices[0].start)146 self.update_rectangle_cpu(dc, timeslice, cpu, self.timeslices[0].start)
146 if cpu > self.max_cpu:
147 self.max_cpu = cpu
148 147
149 def on_paint(self, event):148 def on_paint(self, event):
150 color = wx.Colour(0xff, 0xff, 0xff)149 color = wx.Colour(0xff, 0xff, 0xff)
@@ -163,7 +162,7 @@ class RootFrame(wx.Frame): · 12 unmodified lines
163 cpu = y / (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)162 cpu = y / (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
164 height = y % (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)163 height = y % (RootFrame.CPU_HEIGHT + RootFrame.CPU_SPACE)
165 164
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:
167 return -1166 return -1
168 167
169 return cpu168 return cpu
@@ -206,7 +205,7 @@ class RootFrame(wx.Frame): · 36 unmodified lines
206 self.update_width_virtual()205 self.update_width_virtual()
207 (xpos, ypos) = self.scroll.GetViewStart()206 (xpos, ypos) = self.scroll.GetViewStart()
208 xpos = self.us_to_px(x) / self.scroll_scale207 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)
210 self.Refresh()209 self.Refresh()
211 210
212 def zoom_in(self):211 def zoom_in(self):
@@ -234,7 +233,11 @@ class RootFrame(wx.Frame): · 21 unmodified lines
234 if key == wx.WXK_RIGHT:233 if key == wx.WXK_RIGHT:
235 self.scroll.Scroll(x + 1, y)234 self.scroll.Scroll(x + 1, y)
236 elif key == wx.WXK_LEFT:235 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)
238 241
239 242
240threads = { 0 : "idle"}243threads = { 0 : "idle"}
@@ -504,6 +507,14 @@ class TimeSliceList(UserList): · 263 unmodified lines
504 507
505 return (self.data[0].start, self.data[-1].end)508 return (self.data[0].start, self.data[-1].end)
506 509
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
507 518
508class SchedEventProxy:519class SchedEventProxy:
509 def __init__(self):520 def __init__(self):