<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Gets the current resource usages</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.getopt.html">getopt</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ini-alter.html">ini_alter</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.getrusage" class="refentry"> <div class="refnamediv"> <h1 class="refname">getrusage</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">getrusage</span> — <span class="dc-title">Gets the current resource usages</span></p> </div> <div class="refsect1 description" id="refsect1-function.getrusage-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>getrusage</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$who</code><span class="initializer"> = 0</span></span> ] )</div> <p class="para rdfs-comment"> This is an interface to <strong class="command">getrusage(2)</strong>. It gets data returned from the system call. </p> </div> <div class="refsect1 parameters" id="refsect1-function.getrusage-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">who</code></em></span> <dd> <p class="para"> If <em><code class="parameter">who</code></em> is 1, getrusage will be called with <strong><code>RUSAGE_CHILDREN</code></strong>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.getrusage-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an associative array containing the data returned from the system call. All entries are accessible by using their documented field names. </p> </div> <div class="refsect1 examples" id="refsect1-function.getrusage-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-498"> <p><strong>Example #1 <span class="function"><strong>getrusage()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$dat </span><span style="color: #007700">= </span><span style="color: #0000BB">getrusage</span><span style="color: #007700">();<br />echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_nswap"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// number of swaps<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_majflt"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// number of page faults<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_utime.tv_sec"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// user time used (seconds)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_utime.tv_usec"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// user time used (microseconds)<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.getrusage-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is not implemented on Windows platforms.</span></p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.getrusage-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member">Your system's man page on <strong class="command">getrusage(2)</strong></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.getopt.html">getopt</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ini-alter.html">ini_alter</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>