mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
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
22 lines
587 B
Bash
Executable file
22 lines
587 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# sample-cycles.sh - sample system-wide CPU cycles while a workload runs.
|
|
#
|
|
# Usage: ./sample-cycles.sh [duration_seconds]
|
|
|
|
DURATION=${1:-30}
|
|
|
|
if ! kldstat | grep -q hwpmc; then
|
|
echo "Loading hwpmc..."
|
|
sudo kldload hwpmc
|
|
fi
|
|
|
|
echo "Sampling CPU cycles for $DURATION seconds..."
|
|
echo "Run a workload (for example, dd if=/dev/perfdemo of=/dev/null \\"
|
|
echo " bs=4096 count=100000) in another terminal now."
|
|
echo
|
|
|
|
sudo pmcstat -S cycles -O pmc.out sleep $DURATION
|
|
echo
|
|
echo "Samples written to pmc.out. Producing top-N report..."
|
|
sudo pmcstat -R pmc.out -T | head -30
|