-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.sh
157 lines (148 loc) · 3.5 KB
/
stats.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
st(){
a=`pwd`
cd "$2"
cat `ls | grep "^\\([^.]*\\).${1}\$" ` | tr -d ' \n\t' | wc -c
cd "$a"
}
metalang=$(st "metalang" "tests/prog")
c=$(st "c" "out")
cc=$(st "cc" "out")
ml=$(st "ml" "out")
funml=$(st "fun.ml" "out")
rkt=$(st "rkt" "out")
php=$(st "php" "out")
pas=$(st "pas" "out")
js=$(st "js" "out")
go=$(st "go" "out")
cl=$(st "cl" "out")
py=$(st "py" "out")
rb=$(st "rb" "out")
cs=$(st "cs" "out")
m=$(st "m" "out")
pl=$(st "pl" "out")
java=$(st "java" "out")
ada=$(st "adb" "out")
vb=$(st "vb" "out")
hs=$(st "hs" "out")
lua=$(st "lua" "out")
scala=$(st "scala" "out")
smalltalk=$(st "st" "out")
forth=$(st "fs" "out")
groovy=$(st "groovy" "out")
fsharp=$(st "fsscript" "out")
c=$(( $c * 1000 / $metalang))
cc=$(( $cc * 1000 / $metalang))
ml=$(( $ml * 1000 / $metalang))
funml=$(( $funml * 1000 / $metalang))
rkt=$(( $rkt * 1000 / $metalang))
php=$(( $php * 1000 / $metalang))
pas=$(( $pas * 1000 / $metalang))
js=$(( $js * 1000 / $metalang))
go=$(( $go * 1000 / $metalang))
cl=$(( $cl * 1000 / $metalang))
py=$(( $py * 1000 / $metalang))
rb=$(( $rb * 1000 / $metalang))
cs=$(( $cs * 1000 / $metalang))
m=$(( $m * 1000 / $metalang))
pl=$(( $pl * 1000 / $metalang))
vb=$(( $vb * 1000 / $metalang))
java=$(( $java * 1000 / $metalang))
ada=$(( $ada * 1000 / $metalang))
hs=$(( $hs * 1000 / $metalang))
lua=$(( $lua * 1000 / $metalang))
scala=$(( $scala * 1000 / $metalang))
smalltalk=$(( $smalltalk * 1000 / $metalang))
forth=$(( $forth * 1000 / $metalang))
groovy=$(( $groovy * 1000 / $metalang))
fsharp=$(( $fsharp * 1000 / $metalang))
file="stats_repartition.dat"
makearcstring(){
local arc=`echo "$1" | rev`
local exarc=`echo "$2" | rev`
local arcint=$(echo ${arc:2} | rev )
local arcfloat=$(echo ${arc:0:2} | rev )
local exarcint=$(echo ${exarc:2} | rev )
local exarcfloat=$(echo ${exarc:0:2} | rev )
echo "[$exarcint.$exarcfloat:$arcint.$arcfloat]"
}
swap(){
local line
local i
local word
while read line; do
for i in $(echo "$line" | rev); do
word=$(echo "$i" | rev)
echo -n "$word "
done
echo
done
}
(echo "c $c
c++ $cc
camlImperatif $ml
camlFonctionnel $funml
racket $rkt
php $php
pascal $pas
javascript $js
go $go
commonLisp $cl
objective-C $m
python $py
ruby $rb
c# $cs
perl $pl
ada $ada
vb.net $vb
haskell $hs
lua $lua
smalltalk $smalltalk
scala $scala
forth $forth
java $java
groovy $groovy
fsharp $fsharp
" | swap | sort -n | swap ) > "$file"
filestatsplot(){
IFS='
'
sum=0
for i in `cat "$file"`; do
lng=`echo "$i" | cut -d ' ' -f 1`
size=`echo "$i" | cut -d ' ' -f 2`
sum=$(( $sum + $size ))
done
position="center screen 0.5, 0.5"
echo "
set terminal pngcairo transparent size 800, 600
set output 'repartition.png'
set title \"repartition des langages\"
set style fill solid 0.25 noborder
set boxwidth 0.75
set grid y
set yrange [0:*]
set xtic rotate by -65 scale 0 font \",8\""
exarc=0
n=10
# lignes commentées pour la création d'un camembert
for i in `cat "$file"`; do
n=$(($n + 1))
lng=`echo "$i" | cut -d ' ' -f 1`
size=`echo "$i" | cut -d ' ' -f 2`
echo "# $lng : $size ($sum)"
arc=$(( $exarc + 36000 * $size / $sum))
arcstr=$(makearcstring $arc $exarc)
echo "
#set object $n circle $position, 0 size screen 0.4 arc $arcstr
#set object $n front lw 1.0 fillstyle solid 1.00 border lt -1
"
exarc=$arc
done
echo "
set size ratio -1 1,1
plot 'stats_repartition.dat' using 2:xtic(1) notitle with boxes,\
'' using 0:(\$2/2):2 with labels center offset 0,0 rotate by 90 notitle
"
}
filestatsplot > stats.plot
gnuplot stats.plot