45 lines
1.1 KiB
R
45 lines
1.1 KiB
R
args = commandArgs(trailingOnly=TRUE)
|
|
if (length(args)==0) {
|
|
filename="~/code/FRET/state2gantt/trace.csv"
|
|
} else {
|
|
filename=args[1]
|
|
}
|
|
trace <- read.csv(filename)
|
|
|
|
task_ids = unique(trace[[3]]) # assume this has descending prio order
|
|
prio_from_name <- function(t) {
|
|
1 + length(task_ids) - Position(function(y) y==t, task_ids)
|
|
}
|
|
|
|
trace[[3]]=sapply(trace[[3]], prio_from_name )
|
|
|
|
width = 710
|
|
height = (9/16) * width
|
|
if (length(args)>0) { png(file=sprintf("%s.png",filename), width=width, height=height) }
|
|
# prepare an empty plot
|
|
plot(c(trace[[2]][1],trace[[2]][length(trace[[2]])]),
|
|
c(0,length(task_ids)),
|
|
col = "white", xlab = "", ylab = "")
|
|
# draw all segments
|
|
segments(x0 = trace$start,
|
|
y0 = trace$name,
|
|
x1 = trace$end,
|
|
y1 = trace$name,
|
|
lwd = 3)
|
|
|
|
highlight_prio <- function(p,col) {
|
|
interest = trace[which(trace[[3]] == p),]
|
|
segments(x0 = interest$start,
|
|
y0 = interest$name,
|
|
x1 = interest$end,
|
|
y1 = interest$name,
|
|
lwd = 3,
|
|
col = col)
|
|
}
|
|
|
|
highlight_prio(1,"red")
|
|
#highlight_prio(2,"green")
|
|
|
|
if (length(args)>0) { dev.off() }
|
|
|