-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
66 lines (55 loc) · 2.18 KB
/
graph.py
File metadata and controls
66 lines (55 loc) · 2.18 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
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import platform
import os
import psutil
NUM_THREADS = [1, 2, 4, 8, 16, 32]
RESULTS_FOLDER = f'./{sys.argv[1]}'
AFFINITY = sys.argv[2] if len(sys.argv) == 3 else None
def read_data(method: str) -> list[pd.DataFrame]:
all_results = []
base_path = f"{RESULTS_FOLDER}/{method}_{AFFINITY}" if AFFINITY != None else f"{RESULTS_FOLDER}/{method}"
for i in NUM_THREADS:
results = pd.read_csv(f"{base_path}_{i}.csv")
all_results.append(results)
return all_results
def read_concurrent_data() -> list[pd.DataFrame]:
return read_data("concurrent")
def read_independent_data() -> list[pd.DataFrame]:
return read_data("independent")
def generate_current_graphs() -> None:
data = read_concurrent_data()
generate_graph("Concurrent", data)
def generate_independent_graphs()-> None:
data = read_independent_data()
generate_graph("Independent", data)
def generate_graph(method: str, all_results: list[pd.DataFrame]) -> None:
plt.close() # Close the previous figure to avoid overlapping
plt.rcParams["axes.prop_cycle"] = plt.cycler(
color=plt.rcParams['axes.prop_cycle'].by_key()['color'][:6],
marker=['o', 's', 'D', '^', 'v', '*'])
for i in range(len(NUM_THREADS)):
xs = all_results[i]["hash_bits"]
ys = all_results[i]["mil_tup_per_sec"]
plt.plot(xs, ys, label=f"{NUM_THREADS[i]} threads")
# Get the system and hardware information
current_processor = platform.processor()
physical_cores = psutil.cpu_count(logical=False)
logical_cores = psutil.cpu_count(logical=True)
system_os = platform.system() # e.g. Windows, Linux
title = f"{method} Method on {system_os} {current_processor} {physical_cores}/{logical_cores} cores"
plt.title(title)
plt.legend()
## xticks even only
plt.xlabel("Hash bits")
plt.xticks(range(0, 20, 2))
plt.ylabel("Million tuples per second")
plt.savefig(f"{RESULTS_FOLDER}/{method.lower()}_fig.png")
def main():
# When running the script, it will generate the graphs
generate_current_graphs()
generate_independent_graphs()
if __name__ == '__main__':
main()