-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.sh
More file actions
executable file
·74 lines (61 loc) · 1.41 KB
/
memory.sh
File metadata and controls
executable file
·74 lines (61 loc) · 1.41 KB
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
#!/bin/bash
declare -a lines1
while IFS= read -r line
do
lines1+=("$line")
done < "$1"
declare -a lines2
while IFS= read -r line
do
lines2+=("$line")
done < "$2"
declare -a filenames1
declare -a filenames2
declare -a values1
declare -a values2
for line in "${lines1[@]}"
do
filenames1+=("$(cut -d' ' -f1 <<<"$line")")
values1+=("$(cut -d' ' -f4 <<<"$line")")
done
for line in "${lines2[@]}"
do
filenames2+=("$(cut -d' ' -f1 <<<"$line")")
values2+=("$(cut -d' ' -f4 <<<"$line")")
done
len1=${#filenames1[@]}
len2=${#filenames2[@]}
if [ $len1 != $len2 ]
then
echo "Number of graphs in both the files need to be equal"
exit 1
fi
for (( i=0; i<$len1; i++ ));
do
if [ "${filenames1[$i]}" != "${filenames2[$i]}" ]
then
echo "Graph Names need to be in same order in both files"
exit 1
fi
done
##### MEMORY REDUCTION CALCULATION #####
declare -a output
geomean=1
count=0
for (( i=0; i<$len1; i++ ));
do
output+=($(bc -l <<< "((${values2[$i]} - ${values1[$i]})*100)/${values2[$i]}"))
if [ "${output[$i]}" != 0 ]
then
geomean=($(bc -l <<< "(($geomean*${output[$i]}))"))
count=($(bc -l <<< "$count+1"))
fi
done
output+=($(bc -l <<< "e( l($geomean)/$count )"))
for (( i=0; i<$len1; i++ ));
do
echo -ne "${filenames1[$i]} "
printf "%0.2f\n" "${output[$i]}"
done
echo -ne "GeoMean "
printf "%0.2f\n" "${output[$len1]}"