#!/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:])
Comments
0 B
|π
/π