提交 124c2fc9 编写于 作者: S Stefan Raspl 提交者: Paolo Bonzini

tools/kvm_stat: fix event counts display for interrupted intervals

When an update interval is interrupted via key press (e.g. space), the
'Current' column value is calculated using the full interval length
instead of the elapsed time, which leads to lower than actual numbers.
Furthermore, the value should be rounded, not truncated.
This is fixed by using the actual elapsed time for the calculation.
Signed-off-by: NStefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 773bffee
...@@ -1009,7 +1009,8 @@ class Tui(object): ...@@ -1009,7 +1009,8 @@ class Tui(object):
self.screen.addstr(row, col, '%7.1f' % (values[0] * 100 / total,)) self.screen.addstr(row, col, '%7.1f' % (values[0] * 100 / total,))
col += 7 col += 7
if values[1] is not None: if values[1] is not None:
self.screen.addstr(row, col, '%8d' % (values[1] / sleeptime,)) self.screen.addstr(row, col, '%8d' %
round(values[1] / sleeptime))
row += 1 row += 1
self.screen.refresh() self.screen.refresh()
...@@ -1130,9 +1131,11 @@ class Tui(object): ...@@ -1130,9 +1131,11 @@ class Tui(object):
"""Refreshes the screen and processes user input.""" """Refreshes the screen and processes user input."""
sleeptime = DELAY_INITIAL sleeptime = DELAY_INITIAL
self.refresh_header() self.refresh_header()
start = 0.0 # result based on init value never appears on screen
while True: while True:
self.refresh_body(sleeptime) self.refresh_body(time.time() - start)
curses.halfdelay(int(sleeptime * 10)) curses.halfdelay(int(sleeptime * 10))
start = time.time()
sleeptime = DELAY_REGULAR sleeptime = DELAY_REGULAR
try: try:
char = self.screen.getkey() char = self.screen.getkey()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册