#!/usr/bin/env python

import lxml.etree as ET
import help_parser as hp

def parse_args():
	parser = hp.HelpParser(description='Tool for processing timing data')
	parser.add_argument('data', metavar='data', nargs='+', help='List of XML files')
	return parser.parse_args()

if __name__ == '__main__':
	args = parse_args()
	time = 0
	files = 0
	min_time = 100
	max_time = 0
	for f in args.data:
		elem = ET.parse(f).getroot()
		fold = list(elem)[0]
		files += int(fold.get('usable_files'))
		for d in fold:
			t = float(d.get('time'))
			if t < min_time:
				min_time = t
			if t > max_time:
				max_time = t
			time += t
	print('Avg: ' + str(time/files))
	print('Min: ' + str(min_time))
	print('Max: ' + str(max_time))