Browse Source

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 <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Stefan Raspl 7 years ago
parent
commit
cf656c7661
1 changed files with 8 additions and 1 deletions
  1. 8 1
      tools/kvm/kvm_stat/kvm_stat

+ 8 - 1
tools/kvm/kvm_stat/kvm_stat

@@ -1099,8 +1099,9 @@ class Tui(object):
             sortkey = sortCurAvg
             sortkey = sortCurAvg
         else:
         else:
             sortkey = sortTotal
             sortkey = sortTotal
+        tavg = 0
         for key in sorted(stats.keys(), key=sortkey):
         for key in sorted(stats.keys(), key=sortkey):
-            if row >= self.screen.getmaxyx()[0]:
+            if row >= self.screen.getmaxyx()[0] - 1:
                 break
                 break
             values = stats[key]
             values = stats[key]
             if not values[0] and not values[1]:
             if not values[0] and not values[1]:
@@ -1112,9 +1113,15 @@ class Tui(object):
                 self.screen.addstr(row, 1, '%-40s %10d%7.1f %8s' %
                 self.screen.addstr(row, 1, '%-40s %10d%7.1f %8s' %
                                    (key, values[0], values[0] * 100 / total,
                                    (key, values[0], values[0] * 100 / total,
                                     cur))
                                     cur))
+                if cur is not '' and key.find('(') is -1:
+                    tavg += cur
             row += 1
             row += 1
         if row == 3:
         if row == 3:
             self.screen.addstr(4, 1, 'No matching events reported yet')
             self.screen.addstr(4, 1, 'No matching events reported yet')
+        else:
+            self.screen.addstr(row, 1, '%-40s %10d        %8s' %
+                               ('Total', total, tavg if tavg else ''),
+                               curses.A_BOLD)
         self.screen.refresh()
         self.screen.refresh()
 
 
     def show_msg(self, text):
     def show_msg(self, text):