summaryrefslogtreecommitdiff
path: root/createfiles-plot.sh
blob: c4a7e19c217c42d5735a573aa30c29c75d5a38fd (plain)
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
#!/bin/sh
#
# A small script to generate graphs from createfiles.py output. There will
# be one createfiles-$SIZE.png file for each size of output, graphing the
# various algorithms at various sizes.

set -e

input="$1"

algos=$(awk '$2 == "files/s" { print $3 }' "$input" | sort -u)
sizes=$(awk '/^Measuring/ { print $(NF-1) }' "$input" | sort -un)

for size in $sizes
do
    plot=""
    
    for x in $algos
    do
        awk -vx=$x -vsize=$size '
            /^Measuring/ {
                if ($(NF-1) == size) {
                    n = $6
                    ok = 1
                } else {
                    ok = 0
                }
            }
            ok && $3 == x { 
                print n, $1 >> x ".dat" 
            }' "$input"
        if [ "$plot" = "" ]
        then
            plot="plot \"$x.dat\" with lines"
        else
            plot="$plot, \"$x.dat\" with lines"
        fi
    done

    gnuplot <<eof > "createfiles-$size.png"
set terminal png
set title "Size $size"
$plot
eof

    for x in $algos
    do
        rm "$x.dat"
    done

done