1#1/bin/env bash 2set -e 3 4usage() { 5cat << EOF 6usage: $0 OPTIONS RESULTS_DIR 7 8Convert telemetry json trace result to callstats.html compatible 9versions ot ./out.json 10 11OPTIONS: 12 -h Show this message. 13 RESULTS_DIR tools/perf/artifacts/run_XXX 14EOF 15} 16 17 18while getopts ":h" OPTION ; do 19 case $OPTION in 20 h) usage 21 exit 0 22 ;; 23 ?) echo "Illegal option: -$OPTARG" 24 usage 25 exit 1 26 ;; 27 esac 28done 29 30# ======================================================================= 31 32RESULTS_DIR=$1 33 34if [[ ! -e "$RESULTS_DIR" ]]; then 35 echo "RESULTS_DIR '$RESULTS_DIR' not found"; 36 usage; 37 exit 1; 38fi 39 40 41OUT=out.json 42 43if [[ -e $OUT ]]; then 44 cp --backup=numbered $OUT $OUT.bak 45fi 46 47 48echo '{ "telemetry-results": { "placeholder":{}' > $OUT 49 50for PAGE_DIR in $RESULTS_DIR/*_1; do 51 PAGE=`basename $PAGE_DIR`; 52 JSON="$PAGE_DIR/trace/traceEvents/*_converted.json"; 53 du -sh $JSON; 54 echo "Converting PAGE=$PAGE"; 55 echo "," >> $OUT; 56 echo "\"$PAGE\": " >> $OUT; 57 jq '[.traceEvents[].args | select(."runtime-call-stats" != null) | ."runtime-call-stats"]' $JSON >> $OUT; 58done 59 60 61echo '}}' >> $OUT 62