-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTextFastDropAnalysis.py
More file actions
30 lines (26 loc) · 890 Bytes
/
Copy pathTextFastDropAnalysis.py
File metadata and controls
30 lines (26 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys,re,operator
if __name__ == '__main__':
myRe = re.compile('weight (\d{8,20})')
lastHit = 0
count = 1
lastLine = 0
window = 1024 * 1024 * 1
dropList = []
while True:
line = sys.stdin.readline()
if not line:
break
m = myRe.search(line)
if m:
num = int(m.group(1))
if lastHit - num > window:
dropList.append((lastHit - num,'last hit is {0},last line is {1},current hit is {2},current line is {3}'.format(lastHit,lastLine,num,count)))
lastHit = num
lastLine = count
elif not lastHit:
lastHit = num
lastLine = count
count += 1
dropList = sorted(dropList, key=operator.itemgetter(0),reverse = True)
for d in dropList:
print ':'.join(('dropping {0}'.format(d[0]),d[1]))