-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_3vars.py
69 lines (43 loc) · 1.59 KB
/
plot_3vars.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
"""
E. Wes Bethel, Copyright (C) 2022
October 2022
Description: This code loads a .csv file and creates a 3-variable plot
Inputs: the named file "sample_data_3vars.csv"
Outputs: displays a chart with matplotlib
Dependencies: matplotlib, pandas modules
Assumptions: developed and tested using Python version 3.8.8 on macOS 11.6
"""
import pandas as pd
import matplotlib.pyplot as plt
fname = "sample_data_3vars.csv"
df = pd.read_csv(fname, comment="#")
print(df)
var_names = list(df.columns)
print("var names =", var_names)
# split the df into individual vars
# assumption: column order - 0=problem size, 1=blas time, 2=basic time
problem_sizes = df[var_names[0]].values.tolist()
code1_time = df[var_names[1]].values.tolist()
code2_time = df[var_names[2]].values.tolist()
code3_time = df[var_names[3]].values.tolist()
plt.title("Comparison of 3 Codes")
xlocs = [i for i in range(len(problem_sizes))]
plt.xticks(xlocs, problem_sizes)
# here, we are plotting the raw values read from the input .csv file, which
# we interpret as being "time" that maps directly to the y-axis.
#
# what if we want to plot MFLOPS instead? How do we compute MFLOPS from
# time and problem size? You may need to add some code here to compute
# MFLOPS, then modify the plt.plot() lines below to plot MFLOPS rather than time.
plt.plot(code1_time, "r-o")
plt.plot(code2_time, "b-x")
plt.plot(code3_time, "g-^")
#plt.xscale("log")
#plt.yscale("log")
plt.xlabel("Problem Sizes")
plt.ylabel("runtime")
varNames = [var_names[1], var_names[2], var_names[3]]
plt.legend(varNames, loc="best")
plt.grid(axis='both')
plt.show()
# EOF