forked from Morwenn/cpp-sort
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
34 lines (28 loc) · 923 Bytes
/
Copy pathplot.py
File metadata and controls
34 lines (28 loc) · 923 Bytes
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
import sys
import matplotlib.pyplot as plt
def fetch_results(fresults):
results = fresults.readline().split(' ')
results.pop()
return [int(elem) for elem in results]
if __name__ == '__main__':
# Name and results of timing functions
names = []
values = []
# Fetch the results
with open(sys.argv[1]) as f:
for line in f:
results = line.split(' ')
# Get sorter name
names.append(results.pop(0))
# Remove EOL character
results.pop()
# Plot the results
intresults = [int(elem) for elem in results]
xaxis = list(range(len(intresults)))
val, = plt.plot(xaxis, intresults)
values.append(val)
# Add a legend
plt.legend(values, names, loc='upper left')
plt.xlabel('Number of elements to sort')
plt.ylabel('Execution time (ms)')
plt.show()