clearer names for actions, and infer actions better
[monitor.git] / statistics / comon_analysis.r
1
2 source("functions.r")
3 cm <- read.csv('comon_analysis.txt', sep=',', header=TRUE)
4
5 planetlab_releases <- function (height) 
6 {
7     h = height
8     tstamp_20040412 <-abline_at_date("2004-04-12", col='white', lty=0, height=h)
9     tstamp_20041112 <-abline_at_date("2004-11-12", col='grey60', lty=3, height=h)
10     tstamp_20050301 <-abline_at_date("2005-03-01", col='grey60', lty=3, height=h)
11     tstamp_20050615 <-abline_at_date("2005-06-15", col='white',  lty=0, height=h)
12     tstamp_20051001 <-abline_at_date("2005-10-01", col='grey60', lty=3, height=h)
13     tstamp_20060519 <-abline_at_date("2006-05-19", col='grey60', lty=3, height=h)
14     tstamp_20070228 <-abline_at_date("2007-02-28", col='grey60', lty=3, height=h)
15     tstamp_20070501 <-abline_at_date("2007-05-01", col='white',  lty=0, height=h)
16     tstamp_20071021 <-abline_at_date("2007-10-21", col='grey60', lty=3, height=h)
17     tstamp_20080601 <-abline_at_date("2008-06-01", col='grey60', lty=3, height=h)
18     tstamp_20080815 <-abline_at_date("2008-08-15", col='white',  lty=0, height=h)
19     tstamp_20090501 <-abline_at_date("2009-05-01", col='grey60', lty=3, height=h)
20     tstamp_20100201 <-abline_at_date("2010-02-01", col='white',  lty=0, height=h)
21
22     text(x=c(tstamp_20040412,
23             tstamp_20041112,
24             tstamp_20050301,
25             tstamp_20050615,
26             tstamp_20051001,
27             tstamp_20060519,
28             tstamp_20070228,
29             tstamp_20071021,
30             tstamp_20080601,
31             tstamp_20090501),
32          y=c(h),
33          labels=c('Release', '3.0', '3.1', '', '3.2', '3.3', '4.0', '4.1', '4.2', '4.3')) 
34 }
35
36 # needs:
37 #   xlim=c(min_ts, max_ts)
38 #   labels = names
39 #   at = ts position
40 #   x
41 #   y
42 time_graph_setup <- function (from, to)
43 {
44     # find 'type' range of days
45     xlim <- c(tstamp(from, format="%Y/%m/%d"), tstamp(to, format="%Y/%m/%d"))
46
47     date_months <-seq(as.Date(from), as.Date(to), 'month')
48     date_years <-seq(as.Date(from), as.Date(to), 'year')
49     month_str <- format(date_months, "%b")
50     month_ts <- unclass(as.POSIXct(date_months))
51
52     year_str <- format(date_years, "%Y")
53     year_ts <- unclass(as.POSIXct(date_years))+180*60*60*24
54         
55     return (list(xlim=xlim, month_str=month_str, 
56                  month_ts=month_ts, year_str=year_str, 
57                  year_ts=year_ts))
58 }
59
60 tg <- time_graph_setup('2004/1/1', '2010/6/28')
61
62 #start_image("platform_availability.png")
63 par(mfrow=c(3,1))
64 # bottom, left, top, right margins
65 par(mai=c(0.2, 1, 0.3, 0.1))
66
67
68
69 plot(cm$ts, cm$total, type='l', col='grey60', 
70         axes=F,
71         xlab="",
72         xlim=tg$xlim,
73         ylim=c(0,1000),
74         ylab="a) Online Node Count")
75 lines(cm$ts, cm$online, type='l', col='black' )
76
77 #axis(1, labels=tg$month_str, at=tg$month_ts, cex.axis=0.7)
78 #axis(1, tick=F, labels=tg$year_str, at=tg$year_ts, cex.axis=0.7, line=1)
79 axis(1, labels=c("","","","","","",""), at=tg$year_ts, cex.axis=0.7, line=-0.5)
80 axis(2, las=1)
81 planetlab_releases(1000)
82
83
84 par(mai=c(1, 1, 0.2, 0.1))
85
86 plot(cm$ts, log(cm$X2nd), type='l', col='grey75',
87         axes=F,
88         xlab="",
89         xlim=tg$xlim,
90         ylim=c(7,18), 
91         ylab="b) Node Uptime by Quartile (days)")
92
93 axis(1, labels=tg$month_str, at=tg$month_ts, cex.axis=0.7)
94 axis(1, tick=F, labels=tg$year_str, at=tg$year_ts, cex.axis=0.7, line=1)
95 # TODO: change labels to days up, rather than log(days).
96 d<-c(.1,1,3.5,7,15,30,60,120,240)
97 axis(2, labels=d, at=log(d*60*60*24),las=1)
98
99 lines(cm$ts, log(cm$X3rd), col='black')
100 lines(cm$ts, log(cm$X4th), col='grey50')
101 #lines(cm$ts, log(cm$X5th), col='grey75')
102
103 abline(h=log(max(cm$X2nd[which(!is.na(cm$X2nd))])), col='grey80', lty=2)
104 abline(h=log(max(cm$X3rd[which(!is.na(cm$X3rd))])), col='grey80', lty=2)
105 abline(h=log(max(cm$X4th[which(!is.na(cm$X4th))])), col='grey80', lty=2)
106 #abline(h=log(max(cm$X5th[which(!is.na(cm$X5th))])), col='grey80', lty=2)
107 abline(h=log(7*60*60*24), col='grey80', lty=2)
108
109 planetlab_releases(18)
110
111 #end_image()