-
Notifications
You must be signed in to change notification settings - Fork 3
/
graph-log.py
executable file
·111 lines (76 loc) · 2.18 KB
/
graph-log.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python
# by: John Stultz <[email protected]>
# Copyright 2013 Linaro Limited
#
# Licensed under the GPLv2
#
# This tool requires matplotlib 1.0 or greater to be installed!
import time
import string
import sys
from pylab import *
from datetime import *
from distutils.version import StrictVersion
import matplotlib.dates as mdates
#make sure we've got a recent version fo matplotlib
if (StrictVersion(matplotlib.__version__) < StrictVersion('1.0')):
print "Error: This tool requires matplotlib 1.0 or greater"
sys.exit(-1)
#helpers for tweaking chart size/fonts
normchart = {"dpi":100}
chart_opts = normchart
x = []
act = []
kern = []
ntp = []
freq = []
filename = sys.argv[1]
#Get the commit data
datafile = open(filename, "r")
for line in datafile.read().split("\n"):
if "key" in line:
continue
if not "," in line:
continue
(datestr,dateval,act_off,kern_off,ntp_off,drift,status) = line.split(",")
date = datetime.fromtimestamp(float(dateval))
x.append(date)
act.append(float(act_off))
kern.append(float(kern_off))
ntp.append(float(ntp_off))
freq.append(float(drift))
left, width = 0.1, 0.8
rect1 = [left, 0.2, width, 0.7]
rect3 = [left, 0.1, width, 0.1]
fig = plt.figure()
ax = fig.add_axes(rect1)
ax.plot(x, act, 'g', label="ntpdate offset")
ax.plot(x, kern, 'b', label="kern offset")
ax.plot(x, ntp, 'r', label="ntp offset")
plt.ylabel("offset (sec)")
bx = fig.add_axes(rect3, sharex=ax)
bx.plot(x,freq, 'y')
plt.ylabel("ppm adj")
legend = ax.legend()
legend.get_frame().set_alpha(0.5)
for label in legend.get_texts():
label.set_fontsize('small')
ax.grid(True)
bx.grid(True)
for label in ax.get_xticklabels():
label.set_visible(False)
for label in bx.get_xticklabels():
label.set_rotation(30)
label.set_horizontalalignment('right')
for label in ax.get_yticklabels():
label.set_fontsize('small')
for label in bx.get_yticklabels():
label.set_fontsize('small')
bx.fmt_xdata = mdates.DateFormatter('%Y-%m-%d')
#prune bottom label so we don't have y axis label overlaps
ax.get_yticklabels()[0].set_visible(False)
fig.autofmt_xdate()
plt.margins(0.05, 0.5)
plt.subplots_adjust(bottom=0.15)
plt.savefig(filename+'.png', dpi=chart_opts["dpi"])
#plt.show()