- import os
- import re
- pa = r'C:/logcat.txt'
- route = open(pa,'r')
- con1 = route.readline()
- con2 = route.readline()
- con3 = route.readline()
- con4 = route.readline()
- route.close()
- con1 = con1[0:-1]
- con2 = con2[0:-1]
- con3 = con3[0:-1]
- con4 = con4[0:-1]
- con = [con1,con2,con3,con4]
- for i in con:
- print i,'\\n';
- f = open(i,'r')
- string = f.read()
- f.close()
- cpu = re.findall(r'cpu usage',string)
- thread = re.findall(r'thread exiting with uncaught exception',string)
- pid = re.findall(r'pid: d\\{1,9\\}, tid: d\\{1,9\\}',string)
- Excessive = re.findall(r'Excessive JNI global references',string)
- VM = re.findall(r'VM aborting',string)
- low_level = re.findall(r'Performing low-level shutdown',string)
- Boot = re.findall(r'Received BOOT_COMPLETED',string)
- Framework = re.findall(r'Framework disconnected',string)
- GREF = re.findall(r'GREF count',string)
- print ' cpu usage: ',len(cpu)
- print ' thread exiting with uncaught exception: ',len(thread)
- print ' pid: d{1,9}, tid: d{1,9}: ',len(pid)
- print ' Excessive JNI global references: ',len(Excessive)
- print ' VM aborting: ',len(VM)
- print ' Performing low-level shutdown: ',len(low_level)
- print ' Received BOOT_COMPLETED: ',len(Boot)
- print ' Framework disconnected: ',len(Framework)
- print ' GREF count: ',len(GREF)
- print '\\n'
- os.system('pause')
- #该片段来自于http://www.codesnippet.cn/detail/010820134909.html
来源: http://www.codesnippet.cn/detail/010820134909.html