mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss-extended.git
synced 2025-06-26 23:37:41 +00:00
Cleaning repository
This commit is contained in:
parent
42594cfab4
commit
8260634af4
80 changed files with 169459 additions and 541081 deletions
18
analysis/scheduler/analysis.sh
Executable file
18
analysis/scheduler/analysis.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
wai=$(dirname $(readlink -f "$0")) # Current script directory
|
||||
|
||||
log=$1
|
||||
out=$2
|
||||
|
||||
# Generate csv
|
||||
cat $log | $wai/wakeup.awk > $wai/wakeup.csv
|
||||
cat $log | $wai/data.awk > $wai/data.csv
|
||||
cat $log | $wai/hint.awk > $wai/hint.csv
|
||||
cat $log | $wai/hint_fw.awk > $wai/hint_fw.csv
|
||||
|
||||
cd $wai
|
||||
Rscript ./wakeup.R &> /dev/null || { echo "Schduler data analysis failed"; exit 1; }
|
||||
cd - > /dev/null
|
||||
|
||||
mv $wai/schedule.png $out
|
15
analysis/scheduler/data.awk
Executable file
15
analysis/scheduler/data.awk
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
RS="\n"
|
||||
FS=" "
|
||||
CSV_HEADER="node,ts"
|
||||
CSV_DATA=""
|
||||
skip=1
|
||||
print(CSV_HEADER)
|
||||
}
|
||||
|
||||
/received data success/ {
|
||||
gsub("]","",$0)
|
||||
print($4","$2)
|
||||
}
|
15
analysis/scheduler/hint.awk
Executable file
15
analysis/scheduler/hint.awk
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
RS="\n"
|
||||
FS=" "
|
||||
CSV_HEADER="node,wakets,duration,rcvat"
|
||||
CSV_DATA=""
|
||||
skip=1
|
||||
print(CSV_HEADER)
|
||||
}
|
||||
|
||||
/add a new hint/ {
|
||||
gsub("]","",$0)
|
||||
print($4","$10","$15","$2)
|
||||
}
|
15
analysis/scheduler/hint_fw.awk
Executable file
15
analysis/scheduler/hint_fw.awk
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
RS="\n"
|
||||
FS=" "
|
||||
CSV_HEADER="node,ts"
|
||||
CSV_DATA=""
|
||||
skip=1
|
||||
print(CSV_HEADER)
|
||||
}
|
||||
|
||||
/forward a hint successfully/ {
|
||||
gsub("]","",$0)
|
||||
print($4","$2)
|
||||
}
|
65
analysis/scheduler/wakeup.R
Normal file
65
analysis/scheduler/wakeup.R
Normal file
|
@ -0,0 +1,65 @@
|
|||
library("tidyverse")
|
||||
library("gridExtra")
|
||||
|
||||
pdf(NULL)
|
||||
|
||||
# Load data
|
||||
data=read_csv("wakeup.csv")
|
||||
yorder=str_sort(unique(data$node),numeric=TRUE)
|
||||
data=data%>%mutate(node=factor(node,levels=yorder))
|
||||
|
||||
# Load hint
|
||||
hint=read_csv("hint.csv")
|
||||
|
||||
# Load hint forward
|
||||
hint_fw=read_csv("hint_fw.csv")
|
||||
|
||||
# Load data
|
||||
data_rcv=read_csv("data.csv")
|
||||
|
||||
|
||||
# Configure axis
|
||||
ts_range=seq(0, 24)*3600
|
||||
ts_labels=ts_range/3600
|
||||
|
||||
# Plot
|
||||
p1=ggplot(data,aes(x=wakets,y=node)) + geom_hline(aes(yintercept=node),color="grey",size=3)
|
||||
if(NROW(hint)!=0){
|
||||
p1=p1+geom_vline(data=hint,aes(xintercept=wakets,color="Hint slots"),show.legend = FALSE,linetype="longdash",size=0.3)
|
||||
}
|
||||
p1=p1+geom_linerange(aes(xmin=wakets,xmax=sleepts),size=10)
|
||||
if(NROW(hint)!=0){
|
||||
p1=p1+geom_linerange(data=hint,aes(xmin=wakets,xmax=wakets+duration,color="Hint slots"),size=10)
|
||||
}
|
||||
if(NROW(data_rcv)!=0){
|
||||
p1=p1+geom_point(data=data_rcv,aes(x=ts,color="Data received"),shape=18,size=4)
|
||||
}
|
||||
if(NROW(hint)!=0){
|
||||
p1=p1+geom_point(data=hint,aes(x=rcvat,color="Hint received"),shape=18,size=3)
|
||||
}
|
||||
if(NROW(hint_fw)!=0){
|
||||
p1=p1+geom_point(data=hint_fw,aes(x=ts,color="Hint Forwarded"),shape=18,size=2)
|
||||
}
|
||||
p1=p1+
|
||||
xlab("Time (hours)")+ylab("Node")+
|
||||
scale_x_continuous(breaks = ts_range, labels=ts_labels,expand = c(0, 0))+
|
||||
scale_colour_manual(name="Legend",values=c("Hint slots"="blue","Data received"="red","Hint received"="green","Hint Forwarded"="purple"))+
|
||||
theme(panel.grid.major.x = element_line(size = 1.2),panel.grid.major.y = element_blank(),panel.grid.minor = element_blank())
|
||||
|
||||
stats=data%>%group_by(node)%>%summarise(n=n())%>%mutate(nwakeup=n-24)
|
||||
|
||||
p2=ggplot(stats,aes(x=node,y=nwakeup))+
|
||||
geom_bar(stat="identity")+xlab("Node")+ylab("Extra wake up count")+ylim(0,10)+
|
||||
scale_y_continuous(breaks = seq(0,10))
|
||||
|
||||
stats2=tibble(
|
||||
metric=c("Hint Received","Hint Forwarded","Data Received"),
|
||||
count=c(NROW(hint),NROW(hint_fw),NROW(data_rcv))
|
||||
)
|
||||
|
||||
p3=ggplot(stats2,aes(x=metric,y=count))+
|
||||
geom_bar(stat="identity")+xlab("Metric")+ylab("Count")+ylim(0,20)
|
||||
|
||||
|
||||
p=grid.arrange(p1,p2,p3,heights=c(10,5,5))
|
||||
ggsave(plot=p,"schedule.png",dpi=300,width = 10,height=10)
|
43
analysis/scheduler/wakeup.awk
Executable file
43
analysis/scheduler/wakeup.awk
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
RS="\n"
|
||||
FS=" "
|
||||
CSV_HEADER="node,wakets,sleepts,duration"
|
||||
CSV_DATA=""
|
||||
skip=1
|
||||
}
|
||||
|
||||
/wakes up/{
|
||||
gsub("]","",$0)
|
||||
wakets[$4][length(wakets[$4])+1]=$2
|
||||
skip=0
|
||||
}
|
||||
|
||||
/is sleeping/{
|
||||
gsub("]","",$0)
|
||||
if(!skip){
|
||||
sleepts[$4][length(sleepts[$4])+1]=$2
|
||||
}
|
||||
}
|
||||
|
||||
/LOG2PARSE/{
|
||||
gsub("]","",$0)
|
||||
endts[$6][length(endts[$6])+1]=$2
|
||||
}
|
||||
|
||||
END {
|
||||
print(CSV_HEADER);
|
||||
for(node in wakets){
|
||||
for(j=1;j<=length(wakets[node]);j++){
|
||||
start=wakets[node][j]
|
||||
end=endts[node][1]
|
||||
# Pay attention, the last sleep report for the last wake up is not printed
|
||||
# so use the printed sleep only if available (otherwise we use the en of the simulation)
|
||||
if(j<=length(sleepts[node])){
|
||||
end=sleepts[node][j]
|
||||
}
|
||||
print(node","start","end","end-start)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue