1 slices <- function (x, components=FALSE)
15 slices_2 <- function (x, components=FALSE)
17 # Define an ideal, then scale each measurement relative to the ideal.
18 # If it matches it will be more or less than 1
19 # does this scale (up or down) linearly, and why not?
21 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
28 d<-x$disksize/ideal_d;
29 c<-x$cpuspeed/ideal_c;
30 r<-x$numcores/ideal_r;
42 slices_3 <- function (x, components=FALSE)
44 # Define an ideal, then scale each measurement relative to the ideal.
45 # If it matches it will be more or less than 1
46 # does this scale (up or down) linearly, and why not?
48 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
53 ideal_bw <- 100000; #Kbps
56 d<-x$disksize/ideal_d;
57 c<-x$cpuspeed/ideal_c;
58 r<-x$numcores/ideal_r;
59 b<-log(x$bwlimit)/log(ideal_bw);
71 slices_4 <- function (x, components=FALSE)
73 # Define an ideal, then scale each measurement relative to the ideal.
74 # If it matches it will be more or less than 1
75 # does this scale (up or down) linearly, and why not?
77 # 4, 2.4x2, 1000; 4, 3.2x1, 320; 1, 2.4x1, 160
82 ideal_bw <- 100000; #Kbps
86 d<-x$disksize/ideal_d;
87 c<-x$cpuspeed/ideal_c;
88 r<-x$numcores/ideal_r;
89 b<-log(x$bwlimit)/log(ideal_bw);
90 p<-x$pcustatus/ideal_pcu;
99 return (a/5*5); # I know. Preserved for clarity and consistency with earlier examples
102 index_of_bin <- function (h, value)
106 for (i in sequence(length(h$breaks)))
110 if ( value < h$breaks[1] )
118 if ( i == length(h$breaks) )
127 if ( value > h$breaks[i] && value <= h$breaks[i+1] )
134 warning("index == 0, no bin assigned for value: ", value);
140 start_image <- function (name, width=480, height=480)
142 png(name, width=width, height=height);
145 end_image <- function ()
151 plot_rt_hist <- function (t, imagename=0)
153 d2 <- (t$lastreply - t$start)
154 std_dev <- sd(log(d2))
156 print(sprintf("mean: %s, stddev: %s\n", m, std_dev));
158 if ( imagename != 0 ) { start_image(imagename) }
161 xlab="Hours between ticket creation and final reply",
162 main="Time to Final Reply for RT Tickets", axes=FALSE)
164 a<-exp(h$breaks)/(60*60) # convert units from log(secs) to hours
165 axis(1,labels=signif(a,2), at=h$breaks)
168 x<-seq(min(h$breaks),max(h$breaks),length=500)
169 y<-dnorm(x,mean=m, sd=std_dev)
171 # scale y to the size of h's 'counts' vector rather than the density function
172 lines(x,y*max(h$counts)/max(y))
173 if ( imagename != 0 ) { end_image() }
176 year_hist <- function (t, year, from, to, max, type="week", title="Histogram for Tickets in", fmt="%b-%d")
178 dates <-seq(as.Date(from), as.Date(to), type)
179 months <- format(dates, fmt)
180 hbreaks<-unclass(as.POSIXct(dates))
181 h<-hist(t$start, breaks=hbreaks, plot=FALSE)
182 main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(h$counts))
188 plot(h, ylim=c(0,max), main=main, axes=FALSE)
189 axis(1, labels=months, at=hbreaks)
191 abline(mean(h$counts), 0, col='grey')
198 source("myImagePlot.R")
199 reboot_image <- function (t, year, from, to, max=0, type="week", title="")
201 dates <-seq(as.Date(from), as.Date(to), type)
202 months <- format(dates, "%b-%d")
203 hbreaks<-unclass(as.POSIXct(dates))
206 image <- matrix(data=0, nrow=max(as.numeric(t$hostname)), ncol=length(hbreaks))
207 #image <- matrix(data=0, nrow=length(unique(t$hostname)), ncol=length(hbreaks))
209 #for ( d in hbreaks )
210 for ( i in seq(1, length(hbreaks)) )
212 # find the range : d plus a day
215 # find unique hosts in this day range
216 t_sub <- t[which(t$start > d & t$start <= d_end),]
217 unique_hosts <- unique(t_sub$hostname)
218 if (length(unique_hosts) == 0 ) { next }
220 for ( host in unique_hosts )
226 myImagePlot(image, xLabels=months, yLabels=c(""), title=title)
229 #for ( block in blocks )
231 #print(sprintf("date: %s, block: -%s, %s\n", d, block, host));
232 #print(sprintf("row: %s\n", row));
233 # find the range : 'block' days ago to 'd'
234 # d_back <- d - 60*60*24 * block
235 # t_back_sub <- t[which(t$start > d_back & t$start <= d),]
236 # u <- unique(t_back_sub$hostname)
237 # if ( length(u[u==host]) >= 1)
239 # # add to block_count and go to next host.
241 # i <- as.character(block)
242 # row[i] <- row[i] + 1
249 # row['0'] <- row['0'] + 1
252 #rows <- rbind(rows, c('start'=d, row))
254 #rows <- data.frame(rows)
257 # max = max(rows['0'])
259 #main<-sprintf(paste(title, "%s: MEAN %s\n"), year, mean(rows$reboots))
261 #barplot(rows$reboots, ylim=c(0,max), main=main, axes=FALSE, space=0)
262 ##plot(h, ylim=c(0,max), main=main, axes=FALSE)
263 #axis(1, labels=months, at=seq(1,length(hbreaks)))
265 #abline(mean(rows$reboots), 0, col='grey')
271 add_year <- function (t)
273 t$year <- c(0) # assign new column with zero value initially
274 for ( i in 1:length(t$start) )
276 d <- as.POSIXlt(t$start[i], origin="1970-01-01")
277 year <- d$year + 1900 # as.numeric(format(d, "%Y"))
283 add_timestamp <- function (t)
285 t$start <- c(0) # assign new column with zero value initially
286 for ( i in 1:length(t$date) )
288 tstamp <-unclass(as.POSIXct(t$date[i], origin="1970-01-01"))[1]
294 convert_datestr <- function (t, format)
296 t$start <- c(0) # assign new column with zero value initially
297 for ( i in 1:length(t$Date) )
299 tstamp <-unclass(as.POSIXct(strptime(t$Date[i], format)))[1]
305 abline_at_date <- function (date, col='black', lty=1, format="%Y-%m-%d", height=0)
307 ts <-unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1]
310 abline(v=ts, col=col, lty=lty)
312 lines(c(ts,ts),c(0,height), col=col, lty=lty)
317 tstamp <- function (date, format="%Y-%m-%d")
319 ts <- unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1]
323 lowess_smooth <- function (x, y, delta=(60*60*24), f=0.02)
325 a<-lowess(x, y, delta=delta, f=f)
329 in_list <- function ( str, str_list )
331 for ( f in str_list )
341 col2hex <- function (colorname, alpha=1)
344 c_rgb <- col2rgb(colorname)
346 hex <- rgb(c_rgb[1,1], c_rgb[2,1], c_rgb[3,1], alpha)
350 printf <- function (...)
352 return(print(sprintf(...)));
355 time_graph_setup <- function (from, to)
357 # find 'type' range of days
358 xlim <- c(tstamp(from, format="%Y/%m/%d"), tstamp(to, format="%Y/%m/%d"))
360 begin_date <- as.Date(from)
361 end_date <- as.Date(to)
363 begin_day <- as.numeric(format(begin_date, "%j"))
364 end_day <- as.numeric(format(end_date, "%j"))
367 date_days <-seq(as.Date(from), as.Date(to), 'day')
368 date_weeks <-seq(as.Date(from), as.Date(to), 'week')
369 date_months <-seq(as.Date(from), as.Date(to), 'month')
370 date_years <-seq(as.Date(from), as.Date(to), 'year')
372 day_str <- format(date_months, "%a")
373 day_ts <- unclass(as.POSIXct(date_days))
375 week_str <- format(date_months, "%W")
376 week_ts <- unclass(as.POSIXct(date_weeks))
378 month_str <- format(date_months, "%b")
379 month_ts <- unclass(as.POSIXct(date_months))
381 year_str <- format(date_years, "%Y")
382 year_ts <- unclass(as.POSIXct(date_years))
384 year_ts_before <- year_ts
389 # center year between begin_day and end_day
391 year_ts[1] <- (xlim[1] + xlim[2]) / 2.0
394 print("multitple years!")
395 # center first year between start day and last day of that year.
397 year_ts[1] <- year_ts[1] + ((365 - begin_day)/2.0)*60*60*24
399 year_ts[l] <- year_ts[l] + ( -begin_day + end_day/2.0)*60*60*24
402 year_ts <- c(year_ts[1], year_ts[seq(2,l-1)] + (180 - begin_day)*60*60*24, year_ts[l])
406 print(year_ts - year_ts_before)
408 return (list(xlim=xlim, day_str=day_str, day_ts=day_ts,
409 week_str=week_str, week_ts=week_ts,
410 month_str=month_str, month_ts=month_ts,
411 year_str=year_str, year_ts=year_ts))
414 planetlab_releases <- function (height)
417 tstamp_20040412 <-abline_at_date("2004-04-12", col='white', lty=0, height=h)
418 tstamp_20041112 <-abline_at_date("2004-11-12", col='white', lty=3, height=h)
419 tstamp_20050301 <-abline_at_date("2005-03-01", col='grey60', lty=3, height=h)
420 tstamp_20050615 <-abline_at_date("2005-06-15", col='white', lty=0, height=h)
421 tstamp_20051001 <-abline_at_date("2005-10-01", col='grey60', lty=3, height=h)
422 tstamp_20060519 <-abline_at_date("2006-05-19", col='grey60', lty=3, height=h)
423 tstamp_20070228 <-abline_at_date("2007-02-28", col='grey60', lty=3, height=h)
424 tstamp_20070501 <-abline_at_date("2007-05-01", col='white', lty=0, height=h)
425 tstamp_20071021 <-abline_at_date("2007-10-21", col='grey60', lty=3, height=h)
426 tstamp_20080601 <-abline_at_date("2008-06-01", col='grey60', lty=3, height=h)
427 tstamp_20080815 <-abline_at_date("2008-08-15", col='white', lty=0, height=h)
428 tstamp_20090501 <-abline_at_date("2009-05-01", col='grey60', lty=3, height=h)
429 tstamp_20100201 <-abline_at_date("2010-02-01", col='white', lty=0, height=h)
430 tstamp_20100628 <-abline_at_date("2010-06-28", col='white', lty=3, height=h)
431 tstamp_20110222 <-abline_at_date("2011-02-22", col='grey60', lty=3, height=h)
432 # I think 5.0 was released 02/22/2011... not 03-09
434 text(x=c(tstamp_20040412,
447 #labels=c('Release', '3.0', '3.1', '', '3.2', '3.3', '4.0', '4.1', '4.2', '4.3'))
448 labels=c('', '', '3.1', '', '3.2', '3.3', '4.0', '4.1', '4.2', '4.3', '', '5.0'))
449 text(x=c(tstamp_20050301), y=c(h), labels=c("Releases"))
452 plc_releases <- function (height)
455 tstamp_pre <-abline_at_date("2004-10-01", col='grey60', lty=3, height=h)
456 tstamp_3_1 <-abline_at_date("2005-03-01", col='grey60', lty=3, height=h)
457 tstamp_3_2 <-abline_at_date("2005-10-01", col='grey60', lty=3, height=h)
458 tstamp_3_3 <-abline_at_date("2006-05-19", col='grey60', lty=3, height=h)
459 tstamp_4_0 <-abline_at_date("2007-02-28", col='grey60', lty=3, height=h)
460 tstamp_4_1 <-abline_at_date("2007-10-21", col='grey60', lty=3, height=h)
461 tstamp_4_2 <-abline_at_date("2008-06-01", col='grey60', lty=3, height=h)
462 tstamp_4_3 <-abline_at_date("2009-05-01", col='grey60', lty=3, height=h)
463 tstamp_5_0 <-abline_at_date("2011-02-22", col='grey60', lty=3, height=h)
474 labels=c('3.1', '3.2', '3.3', '4.0', '4.1', '4.2', '4.3', '5.0'))
475 text(x=c(tstamp_pre), y=c(h), labels=c("Releases"))