用WinDBG開Event Timestamps可以產生下面格式的log:
Fri Sep 21 18:43:50.946 2018 (UTC + 8:00): @#$#^$@#$^
以下python code用來找出兩個指定log中的時間差
import time
index = 0
entry_time_recorded = False
try:
with open ('WinDBG.txt', 'rt') as in_file:
for line_num, line in enumerate(in_file):
#print(line) #Fri Sep 21 18:43:50.946 2018 (UTC + 8:00):
index = line.find('DEBUG: _TMP entry')
if index != -1:
entry_time_str = line[0:19] + line[23:28]
entry_time = time.strptime(entry_time_str, "%a %b %d %H:%M:%S %Y")
#print(entry_time)
entry_time_recorded = True
index = line.find('DEBUG: _TMP exit')
if index != -1:
exit_time_str = line[0:19] + line[23:28]
exit_time = time.strptime(exit_time_str, "%a %b %d %H:%M:%S %Y")
#print(exit_time)
if entry_time_recorded:
entry_time_recorded = False
duration = time.mktime(exit_time) - time.mktime(entry_time)
if duration > 1:
print (duration)
print (str(line_num+1) + " ", line)
print ("Search finish!")
except:
print ("Cannot open file: WinDBG.txt")
input()
沒有留言:
張貼留言
Thanks for your message.