Blog/Statistiques.md

Statistiques.md

Télécharger

Rechercher

Le graphique ci dessous montre le rapport entre la taille du code généré par metalang par langage, lors de l'execution des tests, et la taille des tests. En gros, pour chaque langage, on compte : taille du code générée * 1000 / taille des tests. Pour plus d'objectivité, la taille est exprimée en caractère non blanc.

<img src="repartition.png" class="thumbnail" />

Voici la fonction qui me sert à compter les caractères

st(){
    find "$1" -name "$2" -exec cat {} \; | tr -d ' \n' | wc -c
}

On l'appelle pour chaque langage

metalang=$(st "tests/prog" "*.metalang")
c=$(st "out" "*.c")
cc=$(st "out" "*.cc")
ml=$(st "out" "*.ml")
funml=$(st "out" "*.fun.ml")
rkt=$(st "out" "*.rkt")
php=$(st "out" "*.php")
pas=$(st "out" "*.pas")
js=$(st "out" "*.js")
go=$(st "out" "*.go")
cl=$(st "out" "*.cl")
py=$(st "out" "*.py")
rb=$(st "out" "*.rb")
cs=$(st "out" "*.cs")
m=$(st "out" "*.m")
pl=$(st "out" "*.pl")
java=$(st "out" "*.java")
ml=$(( $ml - $funml ))

Ensuite, on calcule le ration entre les codes générés et metalang

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))
java=$(( $java * 1000 / $metalang))

file="stats_repartition.dat"

Pour trier les lignes, on doit swaper taille et langage pour appeller la commande sort

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
}

On génère le fichier trié :

(echo "c $c
cc $cc
ml $ml
funml $funml
rkt $rkt
php $php
pas $pas
js $js
go $go
cl $cl
m $m
py $py
rb $rb
cs $cs
pl $pl
java $java" | swap | sort | swap ) > "$file"

Puis le fichier plot

filestatsplot(){
    echo "
set terminal pngcairo transparent size 600, 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 -25 scale 0 font \",8\""
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