Skip to content

Commit f1cb7d3

Browse files
committed
update script
1 parent 8be406e commit f1cb7d3

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
import os
3+
import subprocess
4+
import sys
5+
6+
cp_path = '/home/olga/gllgen/ucfs/simpleApp/build/install/simpleApp/lib/*'
7+
files_dir = '/home/olga/gllgen/java7/junit/'
8+
9+
tool = sys.argv[1]
10+
files_dir = sys.argv[2]
11+
cp_path = sys.argv[3]
12+
13+
def run_tool_for_file(tool, file_path):
14+
def get_cmd(mem):
15+
return ['java', '-cp', cp_path, f'-Xmx{mem}m', 'org.ucfs.MainKt', tool, file_path]
16+
17+
18+
cache = {}
19+
20+
def execute(mem):
21+
if mem in cache:
22+
return cache[mem]
23+
24+
cmd = get_cmd(mem)
25+
process = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
26+
return_code = process.returncode
27+
if return_code == 42:
28+
print("it return 42")
29+
exit(1)
30+
cache[mem] = return_code
31+
return return_code
32+
33+
l = 1
34+
r = 64
35+
max = 4*1024
36+
while r <= max:
37+
return_code = execute(r)
38+
if return_code != 0:
39+
l = r
40+
r *= 2
41+
else:
42+
break
43+
print(f"calculate r = {r}")
44+
if r == 2*max:
45+
return r
46+
47+
48+
while l < r - 1:
49+
m = (l + r) // 2
50+
return_code = execute(m)
51+
print(f"for {m} mem get code {return_code}")
52+
53+
if return_code != 0:
54+
l = m
55+
else:
56+
r = m
57+
58+
return l
59+
60+
61+
files = os.listdir(files_dir)
62+
63+
print(tool)
64+
with open(f"{tool}_res.txt", "w") as output:
65+
output.write(f"file,mem\n")
66+
output.flush()
67+
for file in files:
68+
mem = run_tool_for_file(tool, files_dir + file)
69+
print(f"Got for tool = {tool}, file = {file}: {mem}mb")
70+
output.write(f"{file},{mem}\n")
71+
output.flush()

benchmarks/src/test/plots.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
import csv
3+
from matplotlib import pyplot as plt
4+
from pathlib import Path
5+
6+
7+
def get_datasets_files(folder: str) -> dict[str, list[str]]:
8+
return {
9+
10+
dataset_folder: [os.path.join(folder, dataset_folder, file) for file in os.listdir(os.path.join(folder, dataset_folder)) if file.endswith(".csv")]
11+
for dataset_folder in os.listdir(folder) if os.path.isdir(os.path.join(folder, dataset_folder))
12+
}
13+
14+
15+
def read_file_data(file: str, column: int) -> list[float]:
16+
with open(file) as fin:
17+
rdr = csv.DictReader(filter(lambda row: row[0] != "%", fin))
18+
return [float(list(line.values())[column]) for line in rdr]
19+
20+
21+
def read_data(folder: str, column: int) -> dict[str, dict[str, list[float]]]:
22+
datasets_files = get_datasets_files(folder)
23+
return {dataset: {Path(file).stem: read_file_data(file, column) for file in files} for dataset, files in datasets_files.items()}
24+
25+
26+
def draw_fig(folder: str, column: int, filename: str):
27+
dict = read_data(folder, column)
28+
tools = set(tool for tools_values in dict.values() for tool in tools_values.keys())
29+
all_datasets = {tool: [value for _, tools_values in dict.items() for value in tools_values.get(tool, [])] for tool in tools}
30+
31+
result = {"All projects": all_datasets}
32+
result.update(dict)
33+
34+
fig, axs = plt.subplots(len(result))
35+
for (dataset, values), ax in zip(result.items(), axs):
36+
ax.boxplot(values.values(), vert=False, widths=0.6)
37+
ax.set_yticklabels(values.keys())
38+
ax.set_title(dataset, loc='right')
39+
fig.tight_layout()
40+
fig.savefig(filename)
41+
42+
43+
draw_fig("results", 1, "time.png")
44+
# draw_fig(2, "memory.png")

benchmarks/tokens_count.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
filename,tokens
12
ActiveTestSuite.java,242
23
ActiveTestTest.java,376
34
After.java,62

0 commit comments

Comments
 (0)