-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.py
85 lines (69 loc) · 2.42 KB
/
plotter.py
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
# #!/share/apps/python/anaconda/bin/python
# import sys
# import numpy as np
# import pandas as pd
# import matplotlib
# matplotlib.use('Agg')
# import matplotlib.pyplot as plt
# def make_plot(runs):
# "Plot results of timing trials"
# for arg in runs:
# df = pd.read_csv("timing-{0}.csv".format(arg))
# plt.plot(df['size'], df['mflop']/1e3, label=arg)
# plt.xlabel('Dimension')
# plt.ylabel('Gflop/s')
# def show(runs):
# "Show plot of timing runs (for interactive use)"
# make_plot(runs)
# lgd = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
# plt.show()
# def main(runs):
# "Show plot of timing runs (non-interactive)"
# make_plot(runs)
# lgd = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
# plt.savefig('timing.pdf', bbox_extra_artists=(lgd,), bbox_inches='tight')
# if __name__ == "__main__":
# main(sys.argv[1:])
#!/share/apps/python/anaconda/bin/python
import sys
import os
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def make_plot(runs):
"Plot results of timing trials"
for arg in runs:
df = pd.read_csv("timing-{0}.csv".format(arg))
plt.plot(df['size'], df['mflop'] / 1e3, label=arg)
plt.xlabel('Dimension')
plt.ylabel('Gflop/s')
df = pd.read_csv("timing-mine.csv")
print("min: ", min(df["mflop"]))
print("max: ", max(df["mflop"]))
print("avg: ", df["mflop"].mean())
def show(runs):
"Show plot of timing runs (for interactive use)"
make_plot(runs)
lgd = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
plt.show()
def main(runs):
"Show plot of timing runs (non-interactive)"
make_plot(runs)
plt.title("Matmul Performances Over Various Matrix Sizes")
lgd = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
# Determine the filename for saving
base_filename = 'timing'
file_extension = '.pdf'
file_counter = 0
new_filename = f"{base_filename}{file_extension}"
# Check for existing files and generate a new filename if needed
while os.path.exists(new_filename):
file_counter += 1
new_filename = f"{base_filename}{file_counter}{file_extension}"
# Save the figure
plt.savefig(new_filename, bbox_extra_artists=(lgd,), bbox_inches='tight')
print(f"Plot saved as: {new_filename}")
if __name__ == "__main__":
main(sys.argv[1:])