-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_length.py
53 lines (37 loc) · 1.2 KB
/
test_length.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Print out the total number of bytes in each test.
import sys
import re
preludeRegexp = re.compile('INFO - 0 INFO SimpleTest START')
testStartRegexp = re.compile('INFO TEST-START \| (.*)')
inPrelude = True
currTest = None
currSize = 0
testSizes = {}
for l in sys.stdin:
currSize += len(l)
if inPrelude and preludeRegexp.search(l):
inPrelude = False
testSizes['prelude'] = currSize
currSize = 0
continue
m = testStartRegexp.search(l)
if m:
newTest = m.group(1)
if currTest:
testSizes[currTest] = currSize - len(l)
currSize = len(l)
else:
# Previous section was the prelude
assert currSize == len(l)
currTest = newTest
totalSize = 0
for t, size in testSizes.iteritems():
print '{0:10} bytes from test {1}'.format(size, t)
totalSize += size
totalSize += currSize
print '{0:10} bytes from the end'.format(currSize)
print 'total size of', totalSize, 'bytes.'