FDD-book/examples/part-07/ch33-performance/lab03-pmcstat/count-events.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

23 lines
550 B
Bash
Executable file

#!/bin/sh
#
# count-events.sh - count instructions retired and LLC misses during
# a fixed-duration workload window.
#
# Usage: ./count-events.sh [duration_seconds]
DURATION=${1:-10}
if ! kldstat | grep -q hwpmc; then
echo "Loading hwpmc..."
sudo kldload hwpmc
fi
echo "Counting cycles and instructions for $DURATION seconds..."
echo "Run a workload in another terminal now."
echo
sudo pmcstat -c 0 -w $DURATION -s instructions -s cycles
echo
echo "LLC_MISSES count for $DURATION seconds..."
sudo pmcstat -c 0 -w $DURATION -s LLC_MISSES