GenuineSounds icon

MCLogTimes

GenuineSounds | PRO | 01/07/16 06:01:55 AM UTC | 0 ⭐ | 481 πŸ‘οΈ | Never ⏰ | []
Python |

1.49 KB

|

None

|

0 πŸ‘

/

0 πŸ‘Ž

#!/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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    πŸ‘

    /

    πŸ‘Ž