-
Notifications
You must be signed in to change notification settings - Fork 2
/
Logfile2csv.sh
executable file
·122 lines (103 loc) · 2.59 KB
/
Logfile2csv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
######################################################################
#
# This script will check the logfiles, created by RunTests.cmd
# on some Windows Machine...
#
# If everything is okay, the result will be a nice .csv file with
# the calculated average values for the testings. This can be used to
# create some nice diagrams...
#
# /TR 2017-06-04
######################################################################
function error() {
echo "$0: error @ $name: $1"
exit 1
}
#dos2unix *.log
echo -n > $0.csv
for logfile in *.log; do
name=`basename $logfile .log`
# check names
cname="${name}.log"
dname="${name}_d.log"
test ! -f $cname && continue
test ! -f $dname && continue
# counter
ctime=0
dtime=0
cmem=0
dmem=0
sizes=0
# value
CTIME="("
DTIME="("
CMEM="("
DMEM="("
SIZE=""
# compression log
while read line; do
# RunningTime = 1.622
if [[ $line =~ ^RunningTime. ]]; then
x=${line#RunningTime.* }
CTIME="$CTIME $x + "
ctime=$((ctime+1))
continue
fi
# PeakWorkingSetSize = 7440
if [[ $line =~ ^PeakWorkingSetSize. ]]; then
x=${line#PeakWorkingSetSize.* }
CMEM="$CMEM $x + "
cmem=$((cmem+1))
continue
fi
# Size = 80529691
if [[ $line =~ ^Size ]]; then
x=${line#Size = }
if [ ! -z "$SIZE" ]; then
[ $x != $SIZE ] && error "different sizes on same level?"
else
SIZE="$x"
fi
sizes=$((sizes+1))
continue
fi
done < "$cname"
# decompression log
while read line; do
# RunningTime = 1.622
if [[ $line =~ ^RunningTime. ]]; then
x=${line#RunningTime.* }
DTIME="$DTIME $x + "
dtime=$((dtime+1))
continue
fi
# PeakWorkingSetSize = 7440
if [[ $line =~ ^PeakWorkingSetSize. ]]; then
x=${line#PeakWorkingSetSize.* }
DMEM="$DMEM $x + "
dmem=$((dmem+1))
continue
fi
done < "$dname"
# echo "ctime=$ctime cmem=$cmem sizes=$sizes"
[ $ctime != $cmem ] && error "count of ctime != cmem"
[ $ctime != $sizes ] && error "count of ctime != sizes"
[ $dtime != $dmem ] && error "count of dtime != dmem"
CTIME="$CTIME 0) / $ctime"
DTIME="$DTIME 0) / $dtime"
CMEM="$CMEM 0) / $cmem"
DMEM="$DMEM 0) / $dmem"
# calculate the avarage
ctime=`echo $CTIME|bc`
dtime=`echo $DTIME|bc`
cmem=`echo $CMEM|bc`
dmem=`echo $DMEM|bc`
# save this csv line
echo "$name;$ctime;$dtime;$SIZE;$cmem;$dmem" | tee -a $0.csv
done
# sort and give some better name
D=`date +%Y-%m-%d`
cat $0.csv | sort -V > "${D}_$$.csv"
rm -f $0.csv
# unix2dos "${D}_$$.csv"