#!/usr/bin/env bash
set -e
if [ -z "$1" ]
  then
    echo "No Chum URI argument supplied"
    exit -1
fi

OUT_DIR=/tmp/results
rm -fr $OUT_DIR
mkdir -p $OUT_DIR

# ZTRACE for trajectory manager
bazel run //vehicle/common/ztrace:analyze_timing -- --chum_uri "$1" --component=ai_trajectory_manager --format=tree --output_dir=$OUT_DIR

# ZTRACE for trajectory manager
bazel run //vehicle/common/ztrace:analyze_timing -- --chum_uri "$1" --component=cas_filter --format=tree --output_dir=$OUT_DIR

# ZTRACE for CAS prediction server
bazel run //vehicle/common/ztrace:analyze_timing -- --chum_uri "$1" --component=cas_prediction_server --format=tree --output_dir=$OUT_DIR

# Print the ZTRACEs
cat $OUT_DIR/*.ztrace.txt

# Done
echo "... done"
