last bug fixes and test2 & test3

This commit is contained in:
elvis
2022-05-03 23:14:39 +02:00
parent 3fb7c1e886
commit 4b7f15c555
13 changed files with 141 additions and 40 deletions

55
scripts/statistiche.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
LOGFILE="logs/l.log"
READS=$(awk 'BEGIN{cnt=0} /readFile.*successo/{++cnt} END{print cnt}' $LOGFILE)
READSMEANB=$(awk 'BEGIN{cnt=0; tot=0} /readFile.*successo/{where = match($0, /dimensione = ([0-9]+)/, arr); if(where != 0) {++cnt; tot+=strtonum(arr[1])}} END{if(cnt!=0){print tot/cnt} else {print 0}}' $LOGFILE)
NREADS=$(awk 'BEGIN{cnt=0} /readNFile.*successo/{++cnt} END {print cnt}' $LOGFILE)
NREADSMEANN=$(awk 'BEGIN{cnt=0; tot=0} /readNFile.*successo/{where = match($0, /\(n = ([0-9]+)\)/, arr); if(where != 0) {++cnt; tot+=strtonum(arr[1])}} END{if(cnt!=0) {print tot/cnt} else {print 0}}' $LOGFILE)
NREADSMEANB=$(awk 'BEGIN{cnt=0; tot=0} /readNFile/{where = match($0, /totale = ([0-9]+)/, arr); if(where != 0) {++cnt; tot+=strtonum(arr[1])}} END{if(cnt!=0) {print tot/cnt} else {print 0}}' $LOGFILE)
LETTURA=$(echo $READS + $NREADS | bc -l)
WRITES=$(awk 'BEGIN{cnt=0} /writeFile.*successo/{++cnt} END{print cnt}' $LOGFILE)
WRITESMEANB=$(awk 'BEGIN{cnt=0; tot=0} /writeFile.*successo/{where = match($0, /dimensione = ([0-9]+)/, arr); if(where != 0) {++cnt; tot+=strtonum(arr[1])}} END{if(cnt!=0){print tot/cnt} else {print 0}}' $LOGFILE)
LOCKS=$(awk 'BEGIN{cnt=0} /lockFile.*successo/{++cnt} END{print cnt}' $LOGFILE)
OPENLOCKS=$(awk 'BEGIN{cnt=0} /openFile.*flags = [23].*successo/{++cnt} END{print cnt}' $LOGFILE)
UNLOCKS=$(awk 'BEGIN{cnt=0} /unlockFile.*successo/{++cnt} END{print cnt}' $LOGFILE)
CLOSES=$(awk 'BEGIN{cnt=0} /closeFile.*successo/{++cnt} END{print cnt}' $LOGFILE)
NTHREADS=$(awk 'BEGIN{n=0} /Creato threadpool.*/{where = match($0, /dimensione ([0-9]+)/, arr); if(where != 0) {n=strtonum(arr[1])}} END{print n}' $LOGFILE)
T=()
for ((i=0;i<$NTHREADS;i++)); do
T[$i]=$(awk -v i=$i 'BEGIN{cnt=0; pat="Thread "i".*ha servito una richiesta"} $0 ~ pat{++cnt} END{print cnt}' $LOGFILE)
done
MAXNFILES=$(awk 'BEGIN{n=0} /Numero di file massimo.*/{where = match($0, /: ([0-9]+)/, arr); if(where != 0) {n=strtonum(arr[1])}} END{print n}' $LOGFILE)
MAXBFILES=$(awk 'BEGIN{n=0} /Dimensione massima.*/{where = match($0, /: ([0-9.]+)/, arr); if(where != 0) {n=strtonum(arr[1])}} END{print n}' $LOGFILE)
MAXVITTIMS=$(awk 'BEGIN{n=0} /vittima.*/{where = match($0, /: ([0-9.]+)/, arr); if(where != 0) {n=strtonum(arr[1])}} END{print n}' $LOGFILE)
MAXCLIENTS=$(awk 'BEGIN{max=0; cur=0} {where = match($0, /Nuovo client.*/); if(where != 0) {++cur; max = (max<cur)?cur:max}; where = match($0, /Chiusa connessione.*/); if(where != 0) {--cur}} END{print max}' $LOGFILE)
echo "Operazioni di read: $READS (dimensione media: $READSMEANB)"
echo "Operazioni di readN: $NREADS (numero medio: $NREADSMEANN, dimensione media: $NREADSMEANB)"
echo "Operazioni totali di lettura: $LETTURA"
echo "Operazioni di write: $WRITES (dimensione media: $WRITESMEANB)"
echo "Operazioni di lock: $LOCKS"
echo "Operazioni di openlock: $OPENLOCKS"
echo "Operazioni di unlock: $UNLOCKS"
echo "Operazioni di close: $CLOSES"
for ((i=0;i<$NTHREADS;i++)); do
echo "Richieste servite dal worker thread $i: ${T[$i]}"
done
echo "Numero massimo di file: $MAXNFILES"
echo "Dimensione massima dei file: $MAXBFILES MB"
echo "Numero di volte in cui lalgoritmo di rimpiazzamento della cache è stato eseguito per selezionare un file vittima: $MAXVITTIMS"
echo "Massimo numero di connessioni contemporanee: $MAXCLIENTS"