diff options
author | Alon Levy <alevy@redhat.com> | 2011-04-07 23:27:39 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-04-07 23:27:39 +0300 |
commit | 2e4e7ed0032b1335a1dbc74be7d820ba6fc30e84 (patch) | |
tree | 893c0e1d7a2ae2404d2c20d4ae46b0e827b86fe4 | |
parent | 5c1bd13cb3519286c70ff6b6893aa619dffed4fa (diff) |
more surface statistics?
-rwxr-xr-x | spicedump.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spicedump.py b/spicedump.py index 90ca647..aac6ff3 100755 --- a/spicedump.py +++ b/spicedump.py @@ -35,12 +35,29 @@ def show(*line_sources): class SurfaceStatistics(object): def __init__(self): self.s = defaultdict(lambda: defaultdict(lambda: 0)) + self.current = set() + self.streams = set() + self.known_ops = dict(surface_create=self.on_surface_create, + surface_destroy=self.on_surface_destroy, + stream_create=self.on_stream_create) + def on_stream_create(self, sid): + self.streams.add(sid) + def on_surface_destroy(self, sid): + if sid in self.current: + self.current.remove(sid) + def on_surface_create(self, sid): + self.current.add(sid) def add(self, sid, op): self.s[sid][op] += 1 + if op not in self.known_ops: + import pdb; pdb.set_trace() + else: + self.known_ops[op](sid) def show(self): all_surfaces = self.s.keys() ds = self.s.values() ops = set(sum([d.keys() for d in ds], [])) + yield '%20s,%5s' % (len(self.current), len(self.streams)) per_surface = dict([(o, sorted(set([ sid for sid, d in self.s.items() if d[o] > 0 |