PAPI_get_virt_usec(3)
β¨ PAPI_get_virt_usec(3) β like, the PAPI manual, bestie β¨
okay so this is a page from the PAPI manual (that's the library name, bestie, we're in PAPI land π
) and today we're talking about PAPI_get_virt_usec β getting your virtual time counter values in microseconds. let's go π«Ά
π NAME π
PAPI_get_virt_usec β get virtual time counter values in microseconds β¨
πΈ SYNOPSIS πΈ
π Detailed Description π
okay so here's the whole vibe: this function returns the total number of virtual units from some arbitrary starting point (yes, arbitrary β she doesn't tell you where she started, that's just her vibe π).
and like, virtual units accrue every time the process is running in user-mode on behalf of the process. that's the whole thing.
and here's the slay part β like the real time counters, this count is guaranteed to exist on every platform PAPI supports. no cap. every single one. π₯
β οΈ but bestieβ¦ on some platforms, the resolution can be as bad as1/Hzas defined by the operating system. like, as bad as1/Hz. the way that's genuinely tragic. π just know it going in.
π Return values π
PAPI_ECNFLCTβ this one hits if there is no master event set. when does that happen? if the library has not been initialized, or β for threaded applications β if there has been no thread id function defined by thePAPI_thread_initfunction. so like, go define that, bestie πPAPI_ENOMEMβ for threaded applications: if there has not yet been any thread specific master event created for the current thread, and if the allocation of such an event set fails, the call will returnPAPI_ENOMEMorPAPI_ESYS. both. either. she's flexible. π
π¦ Examples π¦
here's the iconic little snippet, presented exactly as-is because we do not mess with code:
s = PAPI_get_virt_cyc();
your_slow_code();
e = PAPI_get_virt_cyc();
printf("Process has run for cycles: %lld\en",e-s);
(yes, it calls PAPI_get_virt_cyc() in the example on the PAPI_get_virt_usec page β that's just how the source code said it, and I am not touching it, periodt. π)
π See also π
PAPIFPAPIPAPIPAPI_get_real_cycPAPI_get_virt_cyc
(yes, PAPI is listed twice. she said "and also me" twice. main character energy. π)
π Author π
Generated automatically by Doxygen for PAPI from the source code. not a human, not a vibe, just a robot doing her little documentation thing π€β¨
Version 7.2.0.0 β dated Wed Jun 25 2025 19:30:48, and that's the footer, bestie, so we're done here π
okay bye, go measure your virtual microseconds, ily π§π
π¦ where this page comes from
- nixos 26.05: papi 7.2.0
- nixpkgs unstable: papi 7.2.0
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: papi-devel 7.2.0-160000.2.2 Β· BSD-3-Clause
- ubuntu resolute: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- ubuntu stonking: libpapi-dev 7.2.0-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms