-r--r--r-- 4055 libcpucycles-20230110/doc/html/api.html raw
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html{overflow-y:scroll}
body{font-family:sans-serif}
p,ul,ol,blockquote,pre{font-size:0.9em;line-height:1.6em}
li p{font-size:1.0em}
blockquote p{font-size:1.0em}
tt{font-size:1.2em}
code{font-size:1.2em}
h1{font-size:1.5em}
h2{font-size:1.3em}
h3{font-size:1.0em}
h1 a{text-decoration:none}
table{border-collapse:collapse}
th,td{border:1px solid black}
table a{text-decoration:none}
table tr{font-size:0.9em;line-height:1.6em}
.links a:hover{text-decoration:underline}
.links a:active{text-decoration:underline}
.links img{width:200px;padding-left:1em}
.links td{border:0px;padding-top:0.5em;padding-bottom:0.5em}
.headline{padding:0;font-weight:bold;font-size:1.5em;vertical-align:top;padding-bottom:0.5em;color:#125d0d}
.navt{display:inline-block;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;
min-width:14%;margin:0;padding:0;padding-left:0.5em;padding-right:0.5em;vertical-align:center;
font-weight:bold;font-size:1.1em;text-align:center;border:1px solid black}
.here{border-bottom:0px;background-color:#ffffff}
.away{background-color:#125d0d;}
.away a{text-decoration:none;display:block;color:#ffffff}
.away a:hover,.away a:active{text-decoration:underline}
.main{margin:0;padding-top:0em;padding-bottom:1%;clear:both}
</style>
<title>
API</title>
</head>
<body>
<div class=headline>
libcpucycles
</div>
<div class=nav>
<div class="navt away"><a href=index.html>Intro</a>
</div><div class="navt away"><a href=download.html>Download</a>
</div><div class="navt away"><a href=install.html>Install</a>
</div><div class="navt here">API
</div><div class="navt away"><a href=counters.html>Counters</a>
</div><div class="navt away"><a href=selection.html>Selection</a>
</div><div class="navt away"><a href=security.html>Security</a>
</div></div>
<div class=main>
<h3>NAME</h3>
<p>cpucycles - count CPU cycles</p>
<h3>SYNOPSIS</h3>
<pre><code>#include <cpucycles.h>
long long count = cpucycles();
long long persecond = cpucycles_persecond();
const char *implementation = cpucycles_implementation();
const char *version = cpucycles_version();
</code></pre>
<p>Link with <code>-lcpucycles</code>. Old systems may also need <code>-lrt</code>.</p>
<h3>DESCRIPTION</h3>
<p><code>cpucycles()</code> returns an estimate for the number of CPU cycles that have
occurred since an unspecified time in the past (perhaps system boot,
perhaps program startup).</p>
<p>Accessing true cycle counters can be difficult on some CPUs and
operating systems. <code>cpucycles()</code> does its best to produce accurate
results, but selects a low-precision counter if the only other option is
failure.</p>
<p><code>cpucycles_persecond()</code> returns an estimate for the number of CPU cycles
per second. This estimate comes from <code>/etc/cpucyclespersecond</code> if that
file exists, otherwise from various OS mechanisms, otherwise from the
<code>cpucyclespersecond</code> environment variable if that is set, otherwise
2399987654.</p>
<p><code>cpucycles_implementation()</code> returns the name of the counter in use:
e.g., <code>"amd64-pmc"</code>.</p>
<p><code>cpucycles_version()</code> returns the <code>libcpucycles</code> version number as a
string: e.g., <code>"20230110"</code>. Results of <code>cpucycles_implementation()</code>
should be interpreted relative to <code>cpucycles_version()</code>.</p>
<p><code>cpucycles</code> is actually a function pointer. The first call to
<code>cpucycles()</code> or <code>cpucycles_persecond()</code> or <code>cpucycles_implementation()</code>
selects one of the available counters and updates the <code>cpucycles</code>
pointer accordingly. Subsequent calls to <code>cpucycles()</code> are thread-safe.</p>
<h3>SEE ALSO</h3>
<p><strong>gettimeofday</strong>(2), <strong>clock_gettime</strong>(2)</p><hr><font size=1><b>Version:</b>
This is version 2023.01.10 of the "API" web page.
</font>
</div>
</body>
</html>