Skip to content

Commit cf656c7

Browse files
Stefan-Rasplbonzini
authored andcommitted
tools/kvm_stat: add line for totals
Add a line for the total number of events and current average at the bottom of the body. Note that both values exclude child trace events. I.e. if drilldown is activated via interactive command 'x', only the totals are accounted, or we'd be counting these twice (see previous commit "tools/kvm_stat: fix child trace events accounting"). Signed-off-by: Stefan Raspl <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 73fab6f commit cf656c7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,9 @@ class Tui(object):
10991099
sortkey = sortCurAvg
11001100
else:
11011101
sortkey = sortTotal
1102+
tavg = 0
11021103
for key in sorted(stats.keys(), key=sortkey):
1103-
if row >= self.screen.getmaxyx()[0]:
1104+
if row >= self.screen.getmaxyx()[0] - 1:
11041105
break
11051106
values = stats[key]
11061107
if not values[0] and not values[1]:
@@ -1112,9 +1113,15 @@ class Tui(object):
11121113
self.screen.addstr(row, 1, '%-40s %10d%7.1f %8s' %
11131114
(key, values[0], values[0] * 100 / total,
11141115
cur))
1116+
if cur is not '' and key.find('(') is -1:
1117+
tavg += cur
11151118
row += 1
11161119
if row == 3:
11171120
self.screen.addstr(4, 1, 'No matching events reported yet')
1121+
else:
1122+
self.screen.addstr(row, 1, '%-40s %10d %8s' %
1123+
('Total', total, tavg if tavg else ''),
1124+
curses.A_BOLD)
11181125
self.screen.refresh()
11191126

11201127
def show_msg(self, text):

0 commit comments

Comments
 (0)