8000 #11 - automate memory tests · SoftageRnD/scala@93cfcc0 · GitHub
[go: up one dir, main page]

S 8000 kip to content

Commit 93cfcc0

Browse files
committed
scala#11 - automate memory tests
1 parent 393b14b commit 93cfcc0

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

memory-usage.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ def create_site(rank, percent_self, percent_accum, live_bytes, live_objs, alloca
2424
return site
2525

2626

27-
def runTest(class_name):
27+
def create_test_sum(allocated_bytes_sum, allocated_objs_sum, class_name, live_bytes_sum, live_objs_sum, test_time):
28+
test_sum = memory_usage_doc.createElement("test_sum")
29+
test_sum.setAttribute("allocated_bytes", str(allocated_bytes_sum))
30+
test_sum.setAttribute("allocated_objs", str(allocated_objs_sum))
31+
test_sum.setAttribute("live_bytes", str(live_bytes_sum))
32+
test_sum.setAttribute("live_objs", str(live_objs_sum))
33+
test_sum.setAttribute("time", test_time)
34+
test_sum.setAttribute("class_name", class_name)
35+
return test_sum
36+
37+
38+
def run_test(class_name):
2839
print str.format("test \"{}\" is starting", class_name)
2940

30-
memory_usage = memory_usage_doc.documentElement
41+
test_time = datetime.now().isoformat()
42+
3143
test = memory_usage_doc.createElement("test")
3244
test.setAttribute("class_name", class_name)
33-
test.setAttribute("time", datetime.now().isoformat())
34-
memory_usage.appendChild(test)
45+
test.setAttribute("time", test_time)
46+
tests.appendChild(test)
3547

3648
os.system("java -agentlib:hprof=heap=sites -cp " +
3749
"memory-usage-benchmarks/target/memory-usage-benchmarks-1.0-SNAPSHOT-jar-with-dependencies.jar " +
@@ -45,10 +57,28 @@ def runTest(class_name):
4557
re.DOTALL)
4658
table = m.group(1)
4759

60+
allocated_bytes_sum = 0
61+
allocated_objs_sum = 0
62+
live_bytes_sum = 0
63+
live_objs_sum = 0
64+
4865
for m in re.finditer(r'\b\s*(\d+)\s*(\d+,\d+%)\s*(\d+,\d+%)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(.+)\s*\b',
4966
table):
50-
sites.appendChild(create_site(m.group(1), m.group(2), m.group(3), m.group(4), m.group(5), m.group(6),
51-
m.group(7), m.group(8), m.group(9)))
67+
live_bytes = m.group(4)
68+
live_objs = m.group(5)
69+
allocated_bytes = m.group(6)
70+
allocated_objs = m.group(7)
71+
sites.appendChild(create_site(m.group(1), m.group(2), m.group(3), live_bytes, live_objs, allocated_bytes,
72+
allocated_objs, m.group(8), m.group(9)))
73+
allocated_bytes_sum += int(allocated_bytes)
74+
allocated_objs_sum += int(allocated_objs)
75+
live_bytes_sum += int(live_bytes)
76+
live_objs_sum += int(live_objs)
77+
78+
tests_sum.appendChild(
79+
create_test_sum(allocated_bytes_sum, allocated_objs_sum, class_name, live_bytes_sum, live_objs_sum, test_time))
80+
81+
return test
5282

5383

5484
os.system("ant")
@@ -59,11 +89,18 @@ def runTest(class_name):
5989
os.chdir("..")
6090

6191
memory_usage_doc = getDOMImplementation().createDocument(None, "memory-usage", None)
92+
memory_usage = memory_usage_doc.documentElement
93+
94+
tests_sum = memory_usage_doc.createElement("tests-sum")
95+
memory_usage.appendChild(tests_sum)
96+
97+
tests = memory_usage_doc.createElement("tests")
98+
memory_usage.appendChild(tests)
6299

63-
runTest("ManyOldMutableSets")
64-
runTest("ManyNewMutableSets")
65-
runTest("BigOldMutableSet")
66-
runTest("BigNewMutableSet")
100+
run_test("ManyOldMutableSets")
101+
run_test("ManyNewMutableSets")
102+
run_test("BigOldMutableSet")
103+
run_test("BigNewMutableSet")
67104

68105
os.remove(JAVA_HPROF_FILE_NAME)
69106

0 commit comments

Comments
 (0)
0