add window size flag, tweak flag documentation
This commit is contained in:
parent
988a4aac4c
commit
6fec8076b4
11
impatient
11
impatient
|
@ -6,16 +6,15 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
WINDOW_SIZE = 100
|
|
||||||
|
|
||||||
SUFFIXES = 'KMGT'
|
SUFFIXES = 'KMGT'
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Display progress and time estimates for arbitrary tasks')
|
parser = argparse.ArgumentParser(description='Display progress and time estimates for arbitrary tasks')
|
||||||
parser.add_argument('-f', '--final', type=str, help='Expected final size/value at completion.')
|
parser.add_argument('-f', '--final', type=str, help='Expected final size/value at completion, optionally with a K/M/G/T suffix')
|
||||||
parser.add_argument('-i', '--interval', type=int, default=10, help='Interval in seconds between samples (default 10)')
|
parser.add_argument('-i', '--interval', type=int, default=10, help='Interval in seconds between samples (default 10)')
|
||||||
|
parser.add_argument('-w', '--window', type=int, default=100, help='Number of samples to keep for the sliding window (default 100)')
|
||||||
tracker_types = parser.add_mutually_exclusive_group(required=True)
|
tracker_types = parser.add_mutually_exclusive_group(required=True)
|
||||||
tracker_types.add_argument('-p', '--path', type=str, help='Track total disk usage of a given path')
|
tracker_types.add_argument('-p', '--path', type=str, help='Track total disk usage of a given path')
|
||||||
tracker_types.add_argument('-c', '--command', type=str, help='Track value returned by a shell command; this should return a single number, optionally followed by K/M/G/T')
|
tracker_types.add_argument('-c', '--command', type=str, help='Track value returned by a shell command; this should return a single number, optionally with a K/M/G/T suffix')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -67,8 +66,8 @@ while True:
|
||||||
samples.append(current)
|
samples.append(current)
|
||||||
if len(samples) < 2:
|
if len(samples) < 2:
|
||||||
continue
|
continue
|
||||||
if len(samples) > WINDOW_SIZE:
|
if len(samples) > args.window:
|
||||||
samples = samples[-WINDOW_SIZE:]
|
samples = samples[-args.window:]
|
||||||
|
|
||||||
rate = (current - samples[0])/((len(samples)-1)*args.interval)
|
rate = (current - samples[0])/((len(samples)-1)*args.interval)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue