#!/usr/bin/env python

import sys,os,time

sizes = dict()
paths = sys.argv[1:]

ljsize = 0
for path in paths: 
  sizes[path] = []
  if len(path) > ljsize: ljsize = len(path)

TIME_INTERVAL = 10.0

def get_size(path):
  return int(os.popen("du -sk "+path).read().split()[0])

def get_rate(sizes,n):
  if len(sizes) - 1 < n: n = len(sizes)-1
  rates = [ float(sizes[-(i+1)]-sizes[-(i+2)]) for i in range(n) ]
  # print n,rates
  if rates:
    return sum(rates)/len(rates)/TIME_INTERVAL/1000.0
  return -1.0

def get_rates(sizes):
  r = [ get_rate(sizes,n) for n in (100,10,1) ]
  return "%3.3f %3.3f %3.3f" % tuple(r)


while True:
  #print
  for path in paths:
    t = time.clock()
    sizes[path].append( get_size(path) )
    du_time = time.clock()-t
    if len(sizes[path]) > 101:
      sizes[path] = sizes[path][-102:]
  for path in paths:
    print path.ljust(ljsize), "%8.0f"%(sizes[path][-1]/1000.0), get_rates(sizes[path])
  time.sleep(TIME_INTERVAL)
