FDD-book/examples/part-07/ch33-performance/lab02-dtrace-scripts/profile-sample.d
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

27 lines
582 B
D

#!/usr/sbin/dtrace -s
/*
* profile-sample.d - kernel-wide profile sample at 997 Hz.
*
* Usage: sudo dtrace -s profile-sample.d
*
* Run a workload in another terminal. Let this script run for
* 30 to 60 seconds, then Ctrl-C. The output is a list of stack
* traces ordered by sample count.
*
* 997 Hz is deliberately not 1000 Hz. Using a prime number avoids
* interference with any 1 Hz, 10 Hz, 100 Hz, or 1000 Hz periodic
* activity that might create systematic bias.
*/
#pragma D option quiet
profile-997
{
@[stack()] = count();
}
END
{
trunc(@, 20);
printa(@);
}