#!/bin/bash
# Run CoreMark-PRO CPU benchmark container
# Output: /workspace/output/result.json (mounted from host)

IMAGE_NAME="coremark_pro_rdk_arm"
IMAGE_TAG="latest"

# Default output directory on host
HOST_OUTPUT_DIR="$(pwd)/example_fs/output"

# Allow override via environment variable
if [ -n "$COREMARK_OUTPUT_DIR" ]; then
    HOST_OUTPUT_DIR="$COREMARK_OUTPUT_DIR"
fi

mkdir -p "$HOST_OUTPUT_DIR"

echo "Running CoreMark-PRO benchmark..."
echo "Output will be saved to: $HOST_OUTPUT_DIR/result.json"
echo ""

docker run --rm \
  --name coremark_pro_rdk_arm \
  --privileged \
  -v "$HOST_OUTPUT_DIR":/workspace/output \
  ${IMAGE_NAME}:${IMAGE_TAG}

echo ""
echo "Benchmark complete. Results saved to: $HOST_OUTPUT_DIR/result.json"
