Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix: fix route table total time
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 23, 2019
1 parent 6a6797e commit 402867c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions gnes/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ def __init__(self, bar_len: int = 20, task_name: str = ''):
self.task_name = task_name

def update(self):
sys.stdout.write('\r')
self.num_bars += 1
if (self.num_bars + 1) % self.bar_len == 0:
sys.stdout.write('\n')
elapsed = time.perf_counter() - self.start_time
elapsed_str = colored('elapsed', 'yellow')
speed_str = colored('speed', 'yellow')
self.num_bars += 1
if self.num_bars % self.bar_len == 0:
sys.stdout.write('\n')

sys.stdout.write(
'{:>10} [{:<{}}] {:>8}: {:3.1f}s {:>8}: {:3.1f} batch/s'.format(
colored(self.task_name, 'cyan'),
Expand All @@ -101,12 +101,13 @@ def update(self):
speed_str,
self.num_bars / elapsed,
))

sys.stdout.flush()
sys.stdout.write('\r')

def __enter__(self):
self.start_time = time.perf_counter()
self.num_bars = -1
sys.stdout.write('\n')
self.num_bars = 0
self.update()
return self

Expand Down

0 comments on commit 402867c

Please sign in to comment.