profil(3)
β¨ profil(3) β execution time profile β¨
okay bestie, so this is a page from the Library Functions Manual for profil(3), and it's giving "let's find out where your program is wasting its whole life" energy. it's a libc thing. let's get into it π
πΈ NAME πΈ
profil β execution time profile
π LIBRARY π
Standard C library (libc, -lc) β yes queen, you get it for free.
β¨ SYNOPSIS β¨
#include <unistd.h>
int profil(unsigned short *buf, size_t bufsiz,
size_t offset, unsigned int scale);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
profil():
- Since glibc 2.21:
_DEFAULT_SOURCE
- In glibc 2.19 and 2.20:
_DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
- Up to and including glibc 2.19:
_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
like. yes. you have to ask for it. gatekeeping much π
π DESCRIPTION π
This routine is literally a little detective π΅οΈβοΈ that shows you in what areas your program spends most of its time. main character sleuthing.
So here's the vibe:
- The argument buf points to bufsiz bytes of core.
- Every virtual 10 milliseconds, the user's program counter (PC) is examined:
- offset is subtracted from it,
- the result is multiplied by scale,
- and then divided by 65536.
- If the resulting value is less than bufsiz, then the corresponding entry in buf is incremented.
- If buf is
NULL, profiling is disabled. (bye bestie π)
β RETURN VALUE β
Zero. Always zero. no notes. it never has a bad day, it never has a good day, it just returns 0. periodt.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
profil()β Thread safety: MT-Unsafe π
so like⦠not thread safe. don't be sending her into a group chat of multiple threads and expecting everything to be chill, because it will not be, and I will not be surprised.
π STANDARDS π
None. she's unstandardized. a rogue icon. no cap.
π¦ HISTORY π¦
Similar to a call in SVr4.
π BUGS π
profil()cannot be used on a program that also usesITIMER_PROFinterval timers (seesetitimer(2)). like they Do Not Coexist. pick a lane.- True kernel profiling provides more accurate results. ngl, if you need accuracy you should be looking at kernel profiling instead β this one is doing its best but it's not the main event.
π₯ SEE ALSO π₯
gprof(1), sprof(1), setitimer(2), sigaction(2), signal(2)
and that's the whole page, bestie π«Ά this one came from Linux man-pages 6.20, dated 2026-02-08 β so go profile responsibly, and remember: if buf is NULL, it's not profiling, it's just vibes β¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, Rickard E. Faith <faith@cs.unc.edu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms