#!/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