#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals import re import sys from collections import Counter import click @click.command('mclog', help='') @click.argument('path') def cli(path): with open(path, 'r') as log: counter = Counter() for line in log: res = re.search(r'Bar (?:Step|\w+): (.*?) took (\d+\.\d+)s', line) if res: what = res.group(1) time = float(res.group(2)) if 'Reloading Texture Manager' in what: what = 'Reloading Texture Manager' if ' - ' in what: what = what.split(' - ', 2)[1] counter[what] += time print('╒═══════════════════════════════════════════════════════════╕') print('│ Minecraft Startup Times │') print('╞════════════════════════════════════════════════╤══════════╡') for what, time in counter.most_common(30): print('│ {:46s} │ {:8.3f} │'.format(what, time)) print('│ {:46s} │ {:8.3f} │'.format('Total*', sum(counter.values()))) print('└────────────────────────────────────────────────┴──────────┘') if __name__ == '__main__': cli(sys.argv[1:])