之前在excel里面分析log數(shù)據(jù),簡直日了*了。 現(xiàn)在用python在處理日志數(shù)據(jù).
主要涉及 matplotlib,open和循環(huán)的使用。
日志內(nèi)容大致如下
2016-10-21 21:07:59,787 [7 MainWindowForm]INFO: update time 136.6314 2016-10-21 21:07:59,908 [7 KinectServer]INFO: lClientSockets[0] elapsed time 16. 2016-10-21 21:07:59,918 [7 KinectServer]INFO: lClientSockets[1] elapsed time 107. 2016-10-21 21:07:59,929 [7 MainWindowForm]INFO: update time 135.1311 2016-10-21 21:08:00,039 [7 KinectServer]INFO: lClientSockets[0] elapsed time 14. 2016-10-21 21:08:00,045 [7 KinectServer]INFO: lClientSockets[1] elapsed time 103. 2016-10-21 21:08:00,053 [7 MainWindowForm]INFO: update time 118.1132
python處理代碼
import matplotlib.pyplot as plt input = open('serverlog.txt', 'r') rangeUpdateTime = [0.0] for line in input: line = line.split() if 'update' in line: rangeUpdateTime.append(float(line[-1])) plt.figure('frame time') plt.subplot(211) plt.plot(rangeUpdateTime, '.r',) plt.grid(True) plt.subplot(212) plt.plot(rangeUpdateTime) plt.grid(True) plt.show()
結(jié)果
真心是又好又快出結(jié)果^_^
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
