Skip to content

Commit 8d4334e

Browse files
committed
Add additional functionality to new test files, and improve Bencher compatibility
1 parent c807a2a commit 8d4334e

File tree

3 files changed

+61
-37
lines changed

3 files changed

+61
-37
lines changed

.github/workflows/bencher.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
--err \
2828
--adapter json \
2929
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
30-
python filesize_benchmark.py
30+
python filesize_benchmark_web.py mini_bencher del
3131
3232
# Performance (latency) benchmark
3333
- name: Track latency benchmarks with Bencher
@@ -40,4 +40,4 @@ jobs:
4040
--err \
4141
--adapter json \
4242
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
43-
python latency_benchmark.py
43+
python latency_benchmark_web.py mini_bencher -1 del

bench/filesize_benchmark_web.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
test_dict = dict(toml_graphs["test"])
1616

1717
gont_dict = dict(toml_graphs["1000gont"])
18+
19+
smoke_files = [test_dict["k"]]
1820

1921
mini_files = [test_dict["lpa"], test_dict["chr6c4"], hprc_dict["chrM"]]
2022

2123
med_files = [hprc_dict["chr20"], hprc_dict["chrX"], gont_dict["chr16"]]
22-
24+
2325
big_files = [hprc_dict["chrY"], hprc_dict["chr1"], hprc_dict["chr10"]]
2426

2527
results = "filesize_benchmark.txt"
@@ -44,23 +46,19 @@ def download_file(target_name, web_file):
4446
subprocess.run(["curl", "-o", target_name, web_file],
4547
check = True)
4648

47-
def benchmark():
48-
test_config = ""
49+
def benchmark(test_config):
4950
test_cond = ""
50-
if len(sys.argv) >= 2:
51-
test_config = sys.argv[1] #Can be either "mini", "med", or "big"
52-
else:
53-
raise ValueError("No arguments provided")
54-
5551
if len(sys.argv) >= 3:
5652
test_cond = sys.argv[2] # Can be "del", or not provided
5753

5854
test_files = []
59-
if test_config == "mini":
55+
if "smoke" in test_config:
56+
test_files = smoke_files
57+
elif "mini" in test_config:
6058
test_files = mini_files
61-
elif test_config == "med":
59+
elif "med" in test_config:
6260
test_files = med_files
63-
elif test_config == "big":
61+
elif "big" in test_config:
6462
test_files = big_files
6563
else:
6664
raise ValueError("Incorrect test config provided")
@@ -81,10 +79,20 @@ def benchmark():
8179
size_bytes_avg /= len(test_files)
8280
return size_bytes_avg / 1000.0
8381

84-
bencher_json = {
85-
"FlatGFA File Size Avg": {
86-
"File": {"value": f"{round(benchmark(), 2)} KB"},
87-
}
88-
}
82+
test_config = ""
83+
if len(sys.argv) >= 2:
84+
test_config = sys.argv[1] # Can be either "smoke", "mini", "med", or "big"
85+
else:
86+
raise ValueError("No arguments provided")
87+
8988

90-
json.dump(bencher_json, sys.stdout)
89+
90+
if "bencher" in test_config:
91+
bencher_json = {
92+
"FlatGFA File Size Avg": {
93+
"File": {"value": round(benchmark(test_config), 2)},
94+
}
95+
}
96+
json.dump(bencher_json, sys.stdout)
97+
else:
98+
print(f"File Size Average: {round(benchmark(test_config), 2)} KB")

bench/latency_benchmark_web.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tomllib
88
import gzip
99
import shutil
10+
from typing import Iterable
1011

1112
with open("bench/graphs.toml", "rb") as f:
1213
toml_graphs = tomllib.load(f)
@@ -16,6 +17,8 @@
1617
test_dict = dict(toml_graphs["test"])
1718

1819
gont_dict = dict(toml_graphs["1000gont"])
20+
21+
smoke_files = [test_dict["k"]]
1922

2023
mini_files = [test_dict["lpa"], test_dict["chr6c4"], hprc_dict["chrM"]]
2124

@@ -45,32 +48,36 @@ def download_file(target_name, web_file):
4548
subprocess.run(["curl", "-o", target_name, web_file],
4649
check = True)
4750

48-
def benchmark():
49-
test_config = ""
51+
def benchmark(test_config):
5052
test_cond = ""
5153
num_iter = 0
52-
if len(sys.argv) >= 2:
53-
test_config = sys.argv[1] #Can be either "mini", "med", or "big"
54-
else:
55-
raise ValueError("No arguments provided")
54+
iter_count = -1
5655

5756
if len(sys.argv) >= 3:
58-
test_cond = sys.argv[2] # Can be "del", or not provided
57+
iter_count = int(sys.argv[2]) # Can be any integer
58+
59+
if len(sys.argv) >= 4:
60+
test_cond = sys.argv[3] # Can be "del", or not provided
5961

6062
test_files = []
61-
if test_config == "mini":
63+
if "smoke" in test_config:
64+
test_files = smoke_files
65+
num_iter = 2
66+
elif "mini" in test_config:
6267
test_files = mini_files
6368
num_iter = 10
64-
elif test_config == "med":
69+
elif "med" in test_config:
6570
test_files = med_files
6671
num_iter = 5
67-
elif test_config == "big":
72+
elif "big" in test_config:
6873
test_files = big_files
6974
num_iter = 2
7075
else:
7176
raise ValueError("Incorrect test config provided")
72-
73-
size_bytes_avg = 0
77+
78+
if not iter_count == -1:
79+
num_iter = iter_count
80+
7481
i = 0
7582
total_time = 0.0
7683
for file in test_files:
@@ -90,10 +97,19 @@ def benchmark():
9097
i += 1
9198
return total_time / (num_iter * len(test_files))
9299

93-
bencher_json = {
94-
"FlatGFA File Size Avg": {
95-
"File": {"value": f"{round(benchmark(), 2)} ms"},
96-
}
97-
}
98100

99-
json.dump(bencher_json, sys.stdout)
101+
test_config = ""
102+
if len(sys.argv) >= 2:
103+
test_config = sys.argv[1] # Can be either "smoke", "mini", "med", or "big"
104+
else:
105+
raise ValueError("No arguments provided")
106+
107+
if "bencher" in test_config:
108+
bencher_json = {
109+
"FlatGFA File Size Avg": {
110+
"File": {"value": round(benchmark(test_config), 2)},
111+
}
112+
}
113+
json.dump(bencher_json, sys.stdout)
114+
else:
115+
print(f"Average latency: {round(benchmark(test_config), 2)} ms")

0 commit comments

Comments
 (0)