summaryrefslogtreecommitdiffstatsci
path: root/utils/run_benchmark
blob: 0d4f8c07b0b4f935b745083f1fb43726e99d5ec1 (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
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
#!/bin/bash

iterations=100
size=256

export DISPLAY=:0

which hostname > /dev/null
if [ $? = 0 ]; then
    host=$(hostname -s)
else
    host=$HOSTNAME
fi

if [ -z "$host" ]; then
    echo "Error: Could not determine hostname"
    exit 1
fi

# This script assumes you've built caskbench in a sub-directory
# named "build-HOST".  It invokes the executable from that build
# tree, and stores the results in a directories named
# results-NNN/HOST-SURFACE.
CASKBENCH="build-${host}/src/caskbench"
if [ ! -e ${CASKBENCH} ]; then
    which caskbench > /dev/null
    if [ $? = 0 ]; then
	CASKBENCH=caskbench
    fi
fi
if [ -z "$CASKBENCH" ]; then
    echo "Could not locate caskbench executable"
    exit 1
fi

run_caskbench() {
    out=$1
    surface=$2
    options=$3

    outjson="${out}/results.json"
    outtxt="${out}/results.txt"
    outcsv="${out}/results.csv"

    rm -f cairo*.png skia*.png
    mkdir -p ${out}
    if [ $? != 0 ]; then
	echo "Error creating ${out}: $?"
	return 1
    fi
    cp ./index.html ${out}/
    echo "== ${surface^^} ==" | tee ${outtxt}
    ${CASKBENCH} -t ${surface} -i ${iterations} -s ${size} -o ${outjson} \
	--enable-output-images ${options} | tee -a ${outtxt}
    if [ $? == 0 ]; then
	mv -f cairo*.png skia*.png ${out}/
    fi
    echo | tee -a ${outtxt}

    # Add csv version of data
    if [ ! -e ${outjson} ]; then
	return 1
    fi
    ./utils/json2csv ${outjson} ${outcsv}
    return 0
}

id=0
results_dir=.
today=$(date +%Y%m%d)
while [ -d "${results_dir}" ]; do
    id=$(( id + 1 ))
    results_dir=$(printf "results-${today}-%02d" $id)
done

surfaces=$(${CASKBENCH} -l)
#echo "MSAA (--enable-egl-sample-buffers)" >> ${results_dir}/comparison.txt
export CAIRO_GL_COMPOSITOR=msaa
for surface in ${surfaces}; do
    run_caskbench "${results_dir}/${host}-${surface}" "${surface}"
done
./utils/compare_runs "${results_dir}/${host}-image/results.json" "${results_dir}/${host}-egl/results.json" \
    >> ${results_dir}/comparison.txt
echo >> ${results_dir}/comparison.txt