summaryrefslogtreecommitdiff
path: root/tcwg-benchmark-results.sh
blob: 6bec8b658d0634c3f64f935b7944cf474b0ffaf8 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash

# Clean: shellcheck -e 2001 ./tcwg-benchmark-results.sh

set -euf -o pipefail

scripts=$(dirname $0)
# shellcheck source=jenkins-helpers.sh
. $scripts/jenkins-helpers.sh

function gather_perf_data ()
{
    local has_perf_logs=$1
    local hw_tag=$2
    local num=$3

    if [ x"$has_perf_logs" = xyes ]; then
	$scripts/../bmk-scripts/perfdatadir2csv.sh \
	    --buildid-dir local --format sample,size --sort-field sample \
	    --perf-bin /usr/lib/linux-tools/$hw_tag/perf \
	    $verbose_opt $num_entries_opt \
	    --results-dir "results-$num/" > "$top_artifacts/results-$num.csv"
    else
	# No perf logs to parse, just copy the plain results.csv.
	# Use 'find' because results.csv is located under
	# results-$num/NODE_NAME/ and we don't want to hardcode
	# NODE_NAME. Since the whole script runs under 'set -f', using
	# '*' does not work.
	mapfile -t this_csv < <(find results-$num -name results.csv)
	if [ "${#this_csv[@]}" -eq 1 ]; then
	    cp -v "${this_csv[@]}" "$top_artifacts/results-$num.csv"
	else
	    echo "ERROR: Found ${#this_csv[@]} CSV results files in results-$num, expecting a single one."
	    exit 1
	fi
    fi
}

convert_args_to_variables "$@"

obligatory_variables results

top_artifacts="${top_artifacts-artifacts}"
verbose="${verbose-false}"
# shellcheck disable=SC2154
num_entries_opt="${num_dsos+--num-dsos $num_dsos} ${num_symbols+--num-symbols $num_symbols}"
entry_threshold="${entry_threshold-5}"
metric="${metric-perf}"
has_perf_logs="${has_perf_logs-yes}"

verbose_opt=""
if $verbose; then
    set -x
    verbose_opt="--verbose"
fi

relative_opt=""
# shellcheck disable=SC2154
if [ x"${results_ref+set}" = x"set" ]; then
    relative_opt="--relative"
    results=("$results_ref" "${results[@]}")
    num=0
else
    num=1
fi

mkdir -p $top_artifacts

results_top="bkp-01.tcwglab:/home/tcwg-benchmark/results"

csvs=""
for i in "${results[@]}"; do
    rsync -az --delete "$results_top-$i/" results-$num/

    case $metric in
    "perf")
	hw_tag="${i%%/*}"
	gather_perf_data $has_perf_logs $hw_tag $num
	;;
    "vect")
	$scripts/../bmk-scripts/vect-data-to-csv.py "results-$num" \
	    "$top_artifacts/results-$num.csv"
	;;
    *)
	echo "ERROR: invalid value for metric: ${metric}"
	exit 1
	;;
    esac

    csvs="$csvs $top_artifacts/results-$num.csv"
    num=$(($num+1))
done

$scripts/../bmk-scripts/csvs2table.py -p $entry_threshold $relative_opt $csvs > $top_artifacts/results.csv

$scripts/../bmk-scripts/csvs2table.py -p 0 $relative_opt $csvs > $top_artifacts/results-full.csv

$scripts/../bmk-scripts/csvs2table.py -p 99 $relative_opt $csvs > $top_artifacts/results-brief.csv