2020-06-30 12:17:52 +00:00
|
|
|
#1/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
cat << EOF
|
2021-01-28 09:25:49 +00:00
|
|
|
usage: $0 OPTIONS RESULTS_DIR | TRACE_JSON
|
2020-06-30 12:17:52 +00:00
|
|
|
|
|
|
|
Convert telemetry json trace result to callstats.html compatible
|
|
|
|
versions ot ./out.json
|
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-h Show this message.
|
|
|
|
RESULTS_DIR tools/perf/artifacts/run_XXX
|
2021-01-28 09:25:49 +00:00
|
|
|
TRACE_JSON .json trace files
|
2020-06-30 12:17:52 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while getopts ":h" OPTION ; do
|
|
|
|
case $OPTION in
|
|
|
|
h) usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
?) echo "Illegal option: -$OPTARG"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# =======================================================================
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
if [[ "$1" == *.json ]]; then
|
|
|
|
echo "Converting json files"
|
|
|
|
JSON=$1
|
|
|
|
elif [[ -e "$1" ]]; then
|
|
|
|
echo "Converting reults dir"
|
|
|
|
RESULTS_DIR=$1
|
|
|
|
else
|
2020-06-30 12:17:52 +00:00
|
|
|
echo "RESULTS_DIR '$RESULTS_DIR' not found";
|
|
|
|
usage;
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
OUT=out.json
|
|
|
|
if [[ -e $OUT ]]; then
|
2021-01-28 09:25:49 +00:00
|
|
|
echo "# Creating backup for $OUT"
|
2022-02-17 15:56:09 +00:00
|
|
|
cp $OUT $OUT.bak
|
2020-06-30 12:17:52 +00:00
|
|
|
fi
|
2021-01-28 09:25:49 +00:00
|
|
|
echo "# Writing to $OUT"
|
2020-06-30 12:17:52 +00:00
|
|
|
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
function convert {
|
|
|
|
NAME=$1
|
|
|
|
JSON=$2
|
2022-02-17 15:56:09 +00:00
|
|
|
# Check if any json file exists:
|
|
|
|
if ls $JSON 1> /dev/null 2>&1; then
|
|
|
|
du -sh $JSON;
|
|
|
|
echo "Converting NAME=$NAME";
|
|
|
|
echo "," >> $OUT;
|
|
|
|
echo "\"$NAME\": " >> $OUT;
|
|
|
|
jq '[.traceEvents[].args | select(."runtime-call-stats" != null) | ."runtime-call-stats"]' $JSON >> $OUT;
|
|
|
|
fi
|
2021-01-28 09:25:49 +00:00
|
|
|
}
|
2020-06-30 12:17:52 +00:00
|
|
|
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
echo '{ "telemetry-results": { "placeholder":{}' > $OUT
|
|
|
|
if [[ $RESULTS_DIR ]]; then
|
|
|
|
for PAGE_DIR in $RESULTS_DIR/*_1; do
|
|
|
|
NAME=`basename $PAGE_DIR`;
|
|
|
|
JSON="$PAGE_DIR/trace/traceEvents/*_converted.json";
|
|
|
|
convert $NAME $JSON
|
|
|
|
done
|
|
|
|
else
|
|
|
|
for JSON in $@; do
|
|
|
|
convert $JSON $JSON
|
|
|
|
done
|
|
|
|
fi
|
2020-06-30 12:17:52 +00:00
|
|
|
echo '}}' >> $OUT
|