This repository was archived by the owner on Jan 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_tables.py
More file actions
executable file
·91 lines (77 loc) · 2.96 KB
/
generate_tables.py
File metadata and controls
executable file
·91 lines (77 loc) · 2.96 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
from benchmark import Library
from benchmark import Library
from data_generator import What
from data_generator import What
from datetime import timedelta
from pathlib import Path
from pytablewriter import MarkdownTableWriter
import pandas as pd
import pytimeparse
results_dir = Path("/home/conceptnet/results")
def escape_underscore(s):
return s.replace("_", "\\_")
def collect_load_db_data():
time_dict = {}
ram_dict = {}
disk_dict = {}
time_list = []
ram_list = []
disk_list = []
for library in Library:
with open(results_dir / f"{library.value}_load_db.txt") as f:
time = timedelta(seconds=pytimeparse.parse(f.readline().strip().partition(": ")[2]))
ram = f.readline().strip().partition(": ")[2]
disk = f.readline().strip().partition(": ")[2]
time = f"{time.total_seconds():.1f}"
time_list.append(time)
ram_list.append(ram)
disk_list.append(disk)
header = f"Load database"
time_dict[header] = time_list
ram_dict[header] = ram_list
disk_dict[header] = disk_list
return time_dict, ram_dict, disk_dict
def collect_query_data():
time_dict = {}
ram_dict = {}
disk_dict = {}
for what in What:
time_list = []
ram_list = []
disk_list = []
for library in Library:
with open(results_dir / f"{library.value}_{what.value}_profile.txt") as f:
time = timedelta(seconds=pytimeparse.parse(f.readline().strip().partition(": ")[2]))
ram = f.readline().strip().partition(": ")[2]
disk = f.readline().strip().partition(": ")[2]
time_profile_path = results_dir / f"{library.value}_{what.value}_time_profile.txt"
if time_profile_path.exists():
with open(time_profile_path) as f:
time = timedelta(seconds=float(f.readline().strip()))
time = f"{time.total_seconds():.1f}"
time_list.append(time)
ram_list.append(ram)
disk_list.append(disk)
header = f"Query {escape_underscore(what.value)}"
time_dict[header] = time_list
ram_dict[header] = ram_list
disk_dict[header] = disk_list
return time_dict, ram_dict, disk_dict
def generate_table(name, d):
writer = MarkdownTableWriter()
writer.table_name = name
writer.from_dataframe(
pd.DataFrame(d, index=[escape_underscore(library.value) for library in Library]),
add_index_column=True
)
writer.dump(results_dir / f"{name}.md")
if __name__ == "__main__":
time_dict, ram_dict, disk_dict = collect_load_db_data()
generate_table("Load database time", time_dict)
generate_table("Load database RAM", ram_dict)
generate_table("Load database disk", disk_dict)
time_dict, ram_dict, disk_dict = collect_query_data()
generate_table("Query time", time_dict)
generate_table("Query RAM", ram_dict)
generate_table("Query disk", disk_dict)