- Add summary information to the title once the file is parsed rather than

printing it to the terminal.  Now only parse errors go to the terminal.
 - Speedup drawing by raising and lowering tags only once everything has
   been drawn.  Surprisingly, it now takes a little longer to parse than
   it does to draw.
 - Parameterize the layout with X_ and Y_ defines that determine the sizes
   of various things.
 - Remove unnecessary tags.
This commit is contained in:
Jeff Roberson 2009-01-18 05:44:31 +00:00
parent f2476867dc
commit 932f0fa22e

View File

@ -86,7 +86,7 @@
("lock contest", "purple"),
("failed lock try", "red"),
("lock release", "grey"),
("tick", "black"),
("statclock", "black"),
("prio", "black"),
("lend prio", "black"),
("wokeup", "black")
@ -125,6 +125,12 @@
sources = []
lineno = -1
Y_BORDER = 10
X_BORDER = 10
Y_COUNTER = 80
Y_EVENTSOURCE = 10
XY_POINT = 4
class Colormap:
def __init__(self, table):
self.table = table
@ -674,9 +680,10 @@ def __init__(self, source, name, cpu, timestamp, attrs):
def draw(self, canvas, xpos, ypos):
color = colormap.lookup(self.name)
l = canvas.create_oval(xpos - 6, ypos + 1, xpos + 6, ypos - 11,
l = canvas.create_oval(xpos - XY_POINT, ypos,
xpos + XY_POINT, ypos - (XY_POINT * 2),
fill=color, width=0,
tags=("all", "point", "event", self.name, self.source.tag))
tags=("event", self.type, self.name, self.source.tag))
Event.draw(self, canvas, xpos, ypos, l)
return xpos
@ -701,7 +708,7 @@ def draw(self, canvas, xpos, ypos):
delta = duration / canvas.ratio
l = canvas.create_rectangle(xpos, ypos,
xpos + delta, ypos - 10, fill=color, width=0,
tags=("all", "state", "event", self.name, self.source.tag))
tags=("event", self.type, self.name, self.source.tag))
Event.draw(self, canvas, xpos, ypos, l)
return (xpos + delta)
@ -725,7 +732,7 @@ def draw(self, canvas, xpos, ypos):
yhight = self.source.yscale() * self.count
l = canvas.create_rectangle(xpos, ypos - yhight,
xpos + delta, ypos, fill=color, width=0,
tags=("all", "count", "event", self.name, self.source.tag))
tags=("event", self.type, self.name, self.source.tag))
Event.draw(self, canvas, xpos, ypos, l)
return (xpos + delta)
@ -797,7 +804,8 @@ def draw(self, canvas, ypos):
def drawname(self, canvas, ypos):
self.y = ypos
ypos = ypos - (self.ysize() / 2)
self.item = canvas.create_text(10, ypos, anchor="w", text=self.name)
self.item = canvas.create_text(X_BORDER, ypos, anchor="w",
text=self.name)
return (self.item)
def drawcpu(self, canvas, cpu, fromx, tox, ypos):
@ -807,7 +815,7 @@ def drawcpu(self, canvas, cpu, fromx, tox, ypos):
l = canvas.create_rectangle(fromx,
ypos - self.ysize() - canvas.bdheight,
tox, ypos + canvas.bdheight, fill=color, width=0,
tags=("all", "cpuinfo", cpu, self.tag), state="hidden")
tags=("cpubg", cpu, self.tag), state="hidden")
self.cpuitems.append(l)
def move(self, canvas, xpos, ypos):
@ -818,7 +826,7 @@ def movename(self, canvas, xpos, ypos):
canvas.move(self.item, xpos, ypos)
def ysize(self):
return (10)
return (Y_EVENTSOURCE)
def eventat(self, i):
if (i >= len(self.events)):
@ -858,7 +866,7 @@ def ymax(self):
return (Counter.groups[self.group])
def ysize(self):
return (80)
return (Y_COUNTER)
def yscale(self):
return (self.ysize() / self.ymax())
@ -873,16 +881,22 @@ def __init__(self, file):
self.load = {}
self.crit = {}
self.stathz = 0
self.eventcnt = 0
self.parse(file)
self.fixup()
global ticksps
ticksps = self.ticksps()
timespan = self.timespan()
print "first tick", self.timestamp_f,
print "last tick", self.timestamp_l
print "Ticks per second", ticksps
print "time span", timespan, "ticks", ticks2sec(timespan)
span = self.timespan()
ghz = float(ticksps) / 1000000000.0
#
# Update the title with some stats from the file
#
titlestr = "SchedGraph: "
titlestr += ticks2sec(span) + " at %.3f ghz, " % ghz
titlestr += str(len(sources)) + " event sources, "
titlestr += str(self.eventcnt) + " events"
root.title(titlestr)
def parse(self, file):
try:
@ -990,6 +1004,7 @@ def makeevent(self, group, id, type, args):
elif (type == "point"):
e = PointEvent(source, *args)
if (e != None):
self.eventcnt += 1
source.addevent(e);
return e
@ -1132,13 +1147,10 @@ def draw(self):
ypos += source.ysize()
source.draw(self, ypos)
ypos += self.bdheight
try:
self.tag_raise("point", "state")
self.tag_lower("cpuinfo", "all")
except:
pass
self.tag_raise("point", "state")
self.tag_lower("cpubg", ALL)
self.create_line(0, ypos, xsize, ypos,
width=1, fill="black", tags=("all",))
width=1, fill="black", tags=("lines",))
self.tag_bind("event", "<Enter>", self.mouseenter)
self.tag_bind("event", "<Leave>", self.mouseexit)
self.bind("<Button-1>", self.mousepress)
@ -1187,7 +1199,7 @@ def wheelup(self, event):
self.parent.display_yview("scroll", -1, "units")
def xsize(self):
return ((ktrfile.timespan() / self.ratio) + 20)
return ((ktrfile.timespan() / self.ratio) + (X_BORDER * 2))
def ysize(self):
ysize = 0
@ -1206,7 +1218,7 @@ def scaleset(self, ratio):
self.ratio = ratio
self.updatescroll()
self.scale("all", 0, 0, float(oldratio) / ratio, 1)
self.scale(ALL, 0, 0, float(oldratio) / ratio, 1)
xstart, xend = self.xview()
xsize = (xend - xstart) / 2
@ -1261,7 +1273,7 @@ def __init__(self, master):
self.display = None
self.scale = None
self.status = None
self.bdheight = 10
self.bdheight = Y_BORDER
self.clicksource = None
self.lastsource = None
self.pack(expand=1, fill="both")
@ -1559,7 +1571,7 @@ def getstate(self, tag):
clockfreq = float(sys.argv[2])
root = Tk()
root.title("Scheduler Graph")
root.title("SchedGraph")
colormap = Colormap(eventcolors)
cpucolormap = Colormap(cpucolors)
graph = SchedGraph(root)