10 import matplotlib.colors
as colors
12 import matplotlib.dates
as mdates
13 import matplotlib.ticker
as mticker
14 import matplotlib.mlab
as mlab
15 import matplotlib.pyplot
as plt
24 compute an n period moving average.
26 type is 'simple' | 'exponential'
33 weights = np.exp(np.linspace(-1., 0., n))
35 weights /= weights.sum()
37 a = np.convolve(x, weights, mode=
'full')[:len(x)]
42 print "Graphing " + fn
43 records = csv.reader(open(fn,
'rb'),delimiter=
",")
44 sizes=[]; times=[]; times_seconds=[]; memories=[]
46 sizes.append(int(row[0]))
47 times.append(int(row[1]))
48 memories.append(int(row[2]))
49 times_seconds.append(float(row[3]))
51 left, width = 0.1, 0.8
52 rect1 = [left, 0.5, width, 0.4]
53 rect2 = [left, 0.1, width, 0.4]
55 fig = plt.figure(facecolor=
'white')
58 ax1 = fig.add_axes(rect1, axisbg=axescolor)
59 ax2 = fig.add_axes(rect2, axisbg=axescolor, sharex=ax1)
61 ax1.plot(sizes,times_seconds,color=
'black')
62 if len(times_seconds) > 1000:
63 ax1.plot(sizes,
moving_average(times_seconds,len(times_second) / 100),color=
'blue')
65 oldmemories = list(memories)
66 for i
in range(1,len(memories)): memories[i] = oldmemories[i] - oldmemories[i-1]
67 ax2.plot(sizes,memories,color=
'black')
69 for label
in ax1.get_xticklabels():
70 label.set_visible(
False)
72 class MyLocator(mticker.MaxNLocator):
73 def __init__(self, *args, **kwargs):
74 mticker.MaxNLocator.__init__(self, *args, **kwargs)
76 def __call__(self, *args, **kwargs):
77 return mticker.MaxNLocator.__call__(self, *args, **kwargs)
81 fmt = mticker.ScalarFormatter()
82 fmt.set_powerlimits((-3, 4))
83 ax1.yaxis.set_major_formatter(fmt)
85 ax2.yaxis.set_major_locator(MyLocator(7, prune=
'upper'))
86 fmt = mticker.ScalarFormatter()
87 fmt.set_powerlimits((-3, 4))
88 ax2.yaxis.set_major_formatter(fmt)
89 ax2.yaxis.offsetText.set_visible(
False)
91 size = int(fmt.orderOfMagnitude) / 3
92 labels = [
"B",
"KB",
"MB",
"GB"]
94 labels = [
"",
"(10s)",
"(100s)"]
95 label +=
" " + labels[int(fmt.orderOfMagnitude) % 3]
97 ax2.set_xlabel(
"AtomSpace Size")
98 ax2.set_ylabel(
"RSS " + label)
99 ax1.set_ylabel(
"Time (seconds)")
103 fig.savefig(fn+
".png",format=
"png")
105 files_to_graph = glob.glob(
"*_benchmark.csv")
107 for fn
in files_to_graph: