Skip to content

Instantly share code, notes, and snippets.

@tech4him1
Last active September 8, 2017 20:51
Show Gist options
  • Save tech4him1/17de7a69998c7ade8c1899ed0072db22 to your computer and use it in GitHub Desktop.
Save tech4him1/17de7a69998c7ade8c1899ed0072db22 to your computer and use it in GitHub Desktop.
Check log file for lines that take a lot of time.
import re
YARN_LOGFILE_REGEX = re.compile("^verbose ([0-9\.]*)")
# Maximum time per line.
MAX_TIME = 0.1
with open("install.log", 'r', encoding='utf16') as f:
lines = f.readlines()
for i in range(0, len(lines)):
if i+1 == len(lines):
break
line = lines[i]
nextLine = lines[i+1]
time = YARN_LOGFILE_REGEX.search(line)
nextTime = YARN_LOGFILE_REGEX.search(nextLine)
if (time is None) or (nextTime is None):
continue
if (float(nextTime.group(1)) - float(time.group(1))) > MAX_TIME:
print(line, nextLine, sep='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment