Last active
September 8, 2017 20:51
-
-
Save tech4him1/17de7a69998c7ade8c1899ed0072db22 to your computer and use it in GitHub Desktop.
Check log file for lines that take a lot of time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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