<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.info.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.getrusage.php',
    1 => 'getrusage',
    2 => 'Retourne le niveau d\'utilisation des ressources',
  ),
  'up' => 
  array (
    0 => 'ref.info.php',
    1 => 'Fonctions sur les options et les informations de PHP',
  ),
  'prev' => 
  array (
    0 => 'function.getopt.php',
    1 => 'getopt',
  ),
  'next' => 
  array (
    0 => 'function.ini-alter.php',
    1 => 'ini_alter',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/info/functions/getrusage.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.getrusage" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">getrusage</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">getrusage</span> &mdash; <span class="dc-title">Retourne le niveau d&#039;utilisation des ressources</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.getrusage-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>getrusage</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   C&#039;est une interface à la fonction système <strong class="command">getrusage(2)</strong>.
   Elle retourne un tableau associatif contenant les informations
   renvoyées par cet appel système.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.getrusage-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Si <code class="parameter">mode</code> est égal à 1,
       <span class="function"><strong>getrusage()</strong></span> sera appelé avec
       le paramètre <strong><code>RUSAGE_CHILDREN</code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.getrusage-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne un tableau associatif contenant les données retournées depuis
   l&#039;appel système. Toutes les entrées sont accessibles en utilisant leurs
   noms de champs documentés.
   Retourne <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en cas d&#039;échec.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.getrusage-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>getrusage()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?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_oublock"</span><span style="color: #007700">];       </span><span style="color: #FF8000">// nombre d'opérations de bloc de sortie<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_inblock"</span><span style="color: #007700">];       </span><span style="color: #FF8000">// nombre d'opérations de bloc d'entrée<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_msgsnd"</span><span style="color: #007700">];        </span><span style="color: #FF8000">// nombre de messages IPC envoyés<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_msgrcv"</span><span style="color: #007700">];        </span><span style="color: #FF8000">// nombre de messages IPC reçus<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_maxrss"</span><span style="color: #007700">];        </span><span style="color: #FF8000">// taille maximale du groupe de résidents<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_ixrss"</span><span style="color: #007700">];         </span><span style="color: #FF8000">// taille de la mémoire partagée intégrale<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_idrss"</span><span style="color: #007700">];         </span><span style="color: #FF8000">// taille intégrale des données non partagées<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_minflt"</span><span style="color: #007700">];        </span><span style="color: #FF8000">// nombre de pages récupérées (faute de page mineure)<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">// nombre de défauts de page (faute de page majeure)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_nsignals"</span><span style="color: #007700">];      </span><span style="color: #FF8000">// nombre de signaux reçus<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_nvcsw"</span><span style="color: #007700">];         </span><span style="color: #FF8000">// nombre de changements de contexte volontaires<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_nivcsw"</span><span style="color: #007700">];        </span><span style="color: #FF8000">// nombre de changements de contexte involontaires<br /></span><span style="color: #007700">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">// taille de la mémoire swap<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">// temps utilisateur utilisé (en microsecondes)<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">// temps utilisateur utilisé (en secondes)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_stime.tv_usec"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// temps système utilisé (en microsecondes)<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$dat</span><span style="color: #007700">[</span><span style="color: #DD0000">"ru_stime.tv_sec"</span><span style="color: #007700">]; </span><span style="color: #FF8000">// temps système utilisé (en secondes)<br /></span><span style="color: #0000BB">?&gt;</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>: 
   <p class="para">
    Sous Windows, la fonction <span class="function"><strong>getrusage()</strong></span> ne va retourner
    que les membres suivants :
   </p>
   <p class="para">
    <ul class="simplelist">
     <li><code class="literal">&quot;ru_stime.tv_sec&quot;</code></li>
     <li><code class="literal">&quot;ru_stime.tv_usec&quot;</code></li>
     <li><code class="literal">&quot;ru_utime.tv_sec&quot;</code></li>
     <li><code class="literal">&quot;ru_utime.tv_usec&quot;</code></li>
     <li>
      <code class="literal">&quot;ru_majflt&quot;</code> (seulement si <code class="parameter">mode</code> vaut
      <strong><code>RUSAGE_SELF</code></strong>)
     </li>
     <li>
      <code class="literal">&quot;ru_maxrss&quot;</code> (seulement si <code class="parameter">mode</code> vaut
      <strong><code>RUSAGE_SELF</code></strong>)
     </li>
    </ul>
   </p>
   <p class="para">
    Si <span class="function"><strong>getrusage()</strong></span> est appelé avec le paramètre <code class="parameter">mode</code>
    valant <code class="literal">1</code> (<strong><code>RUSAGE_CHILDREN</code></strong>), alors l&#039;utilisation
    de la ressource pour les threads est collectée (ce qui signifie que, en interne,
    la fonction est appelée avec <strong><code>RUSAGE_THREAD</code></strong>).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Sous BeOS 2000, seuls les membres suivants sont retournés :
   </p>
   <p class="para">
    <ul class="simplelist">
     <li><code class="literal">&quot;ru_stime.tv_sec&quot;</code></li>
     <li><code class="literal">&quot;ru_stime.tv_usec&quot;</code></li>
     <li><code class="literal">&quot;ru_utime.tv_sec&quot;</code></li>
     <li><code class="literal">&quot;ru_utime.tv_usec&quot;</code></li>
    </ul>
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.getrusage-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li>La page de manuel <strong class="command">getrusage(2)</strong> du système</li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>