You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sledge-1/elasped.sh

46 lines
772 B

6 months ago
#!/bin/bash
# <20><>ȡ sledgert <20><><EFBFBD>̵<EFBFBD> PID
SLEDGERT_PID=$(pgrep sledgert)
if [ -z "$SLEDGERT_PID" ]; then
echo "sledgert process not found!"
exit 1
fi
# <20><><EFBFBD><EFBFBD> perf <20><><EFBFBD><EFBFBD>
sudo perf record -e cycles,instructions,cache-misses -p $SLEDGERT_PID -o perf.data &
PERF_PID=$!
# ȷ<><C8B7> perf <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sleep 0.1
# <20><>¼<EFBFBD><C2BC>ʼʱ<CABC><EFBFBD><E4A3A8><EFBFBD>
start=$(date +%s%N)
# <20><><EFBFBD><EFBFBD> HTTP <20><><EFBFBD><EFBFBD>
echo "10" | http :10000
# <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3A8><EFBFBD>
end=$(date +%s%N)
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>
elapsed=$((end - start))
# ת<><D7AA>Ϊ΢<CEAA><CEA2>
elapsed_us=$((elapsed / 1000))
echo "Elapsed time: ${elapsed_us} ?s"
# ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
elapsed_ms=$((elapsed / 1000000))
echo "Elapsed time: ${elapsed_ms} ms"
# ֹͣ perf <20><><EFBFBD><EFBFBD>
sudo pkill -INT -P $PERF_PID
# <20>ȴ<EFBFBD> perf д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
wait $PERF_PID
# <20><>ʾ perf <20><><EFBFBD><EFBFBD>
sudo perf report -i perf.data