FDD-book/examples/appendices/appendix-f-benchmarks/dtrace/dtrace_overhead.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

33 lines
723 B
D

/*
* dtrace_overhead.d - a probe-only DTrace script used to measure
* the per-syscall overhead of attaching DTrace.
*
* The script fires on every syscall entry and return but does not
* print anything per probe. At exit it prints the total counts.
* Attach it while the workload programs run and compare their
* wall-clock times to the baseline.
*
* Usage (as root):
* dtrace -q -s dtrace_overhead.d
*
* Ctrl-C when the workload finishes.
*
* Companion to Appendix F of "FreeBSD Device Drivers: From First
* Steps to Kernel Mastery".
*/
syscall:::entry
{
@entries = count();
}
syscall:::return
{
@returns = count();
}
END
{
printa("entries=%@d\n", @entries);
printa("returns=%@d\n", @returns);
}