plot.py
Go to the documentation of this file.
1 import csv
2 import matplotlib.pyplot as plt
3 import numpy as np
4 
5 real_time = []
6 names = []
7 # load the data
8 with open("doc/data.csv", "r") as cf:
9  plots = csv.DictReader(cf, delimiter=",")
10  for row in plots:
11  real_time.append(float(row['cpu_time']))
12  names.append(row['name'])
13 
14 # create subplots
15 fig, axs = plt.subplots(2, 2)
16 
17 # convert the time form nanoseconds to milliseconds.
18 real_time = np.array(real_time)
19 real_time /= 1e6
20 
21 axs[0, 0].plot(real_time[:10], '--o', label='sob_layer')
22 axs[0, 0].plot(real_time[20:30], '--x', label='infaltion_layer')
23 axs[0, 0].set_title('100x100 square')
24 
25 axs[0, 1].plot(real_time[40:49], '--o', label='sob_layer')
26 axs[0, 1].plot(real_time[58:67], '--x', label='infaltion_layer')
27 axs[0, 1].set_title('100x100 sparse')
28 
29 axs[1, 0].plot(real_time[10:20], '--o', label='sob_layer')
30 axs[1, 0].plot(real_time[30:40], '--x', label='infaltion_layer')
31 axs[1, 0].set_title('1000x1000 square')
32 
33 axs[1, 1].plot(real_time[49:58], '--o',label='sob_layer')
34 axs[1, 1].plot(real_time[67:76], '--x',label='infaltion_layer')
35 axs[1, 1].set_title('1000x1000 sparse')
36 
37 for ax in axs.flat:
38  ax.set(ylabel='cpu_time [ms]', xlabel='occupancy')
39  ax.set_ylim(ymin=0)
40  ax.set_xticklabels([])
41  ax.legend()
42 
43 fig.tight_layout()
44 fig.set_size_inches(10, 10)
45 fig.savefig('doc/stats.png', dpi=100)
46 
47 # now get the relative
48 rel1 = np.array(real_time[20:30]) / np.array(real_time[0:10])
49 rel2 = np.array(real_time[30:40]) / np.array(real_time[10:20])
50 rel3 = np.array(real_time[58:67]) / np.array(real_time[40:49])
51 rel4 = np.array(real_time[67:76]) / np.array(real_time[49:58])
52 
53 fig, axs = plt.subplots(1)
54 plt.plot(rel1, label='relative 100x100 square')
55 plt.plot(rel2, label='relative 1000x1000 square')
56 plt.plot(rel3, label='relative 100x100 sparse')
57 plt.plot(rel4, label='relative 1000x1000 sparse')
58 
59 plt.legend()
60 fig.savefig('doc/relative.png', dpi=100)
plot
Definition: plot.py:1


sob_layer
Author(s):
autogenerated on Wed Mar 2 2022 01:02:42