-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting1.py
40 lines (30 loc) · 1.03 KB
/
testing1.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
# Testing a script that iterates through the pickle trace file until it reaches the end of the file (EOFError).
from sys import argv, exit
import matplotlib.pyplot as plt
import pickle
def main():
# FILES, THESE ARE THE Y-AXIS
traceSet = unpickle("chrome_traces/cnn.com.pkl", multiple=True)[0]
time_axis = range(10000)
for t in traceSet:
plt.plot(time_axis, t, lw=1)
plt.title("Chrome- cnn.com - 10 seconds - 10 runs")
plt.xlabel("Time (ms)")
plt.ylabel("Counter values")
plt.show()
def unpickle(traceFileName, multiple=False):
if multiple:
traceFileHandle = open(traceFileName, "rb")
traceSet = []
while True:
try:
trace, site = pickle.load(traceFileHandle)
traceSet.append(trace[0])
except EOFError:
break
traceFileHandle.close()
return traceSet, site
with open(traceFileName, "rb") as traceFileHandle:
return pickle.load(traceFileHandle)
if __name__ == "__main__":
main()