<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.xhprof.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'pt_BR',
  ),
  'this' => 
  array (
    0 => 'xhprof.examples.php',
    1 => 'Exemplos',
    2 => 'Exemplos',
  ),
  'up' => 
  array (
    0 => 'book.xhprof.php',
    1 => 'Xhprof',
  ),
  'prev' => 
  array (
    0 => 'xhprof.constants.php',
    1 => 'Constantes predefinidas',
  ),
  'next' => 
  array (
    0 => 'ref.xhprof.php',
    1 => 'Fun&ccedil;&otilde;es de Xhprof',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'pt_BR',
    'path' => 'reference/xhprof/examples.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="xhprof.examples" class="chapter">
 <h1 class="title">Exemplos</h1>

 <div class="example" id="example-1">
  <p><strong>Exemplo #1 Exemplo de Xhprof com a GUI opcional</strong></p>
  <div class="example-contents"><p>
   Este exemplo inicia e interrompe o perfilador e, em seguida, usa a interface gráfica
   inclusa para salvar e analisar os resultados. Em outras palavras, o
   código da própria extensão termina na chamada para
   <span class="function"><a href="function.xhprof-disable.php" class="function">xhprof_disable()</a></span>.
  </p></div>
  <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />xhprof_enable</span><span style="color: #007700">(</span><span style="color: #0000BB">XHPROF_FLAGS_CPU </span><span style="color: #007700">+ </span><span style="color: #0000BB">XHPROF_FLAGS_MEMORY</span><span style="color: #007700">);<br /><br />for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt;= </span><span style="color: #0000BB">1000</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) {<br />    </span><span style="color: #0000BB">$a </span><span style="color: #007700">= </span><span style="color: #0000BB">$i </span><span style="color: #007700">* </span><span style="color: #0000BB">$i</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$xhprof_data </span><span style="color: #007700">= </span><span style="color: #0000BB">xhprof_disable</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$XHPROF_ROOT </span><span style="color: #007700">= </span><span style="color: #DD0000">"/tools/xhprof/"</span><span style="color: #007700">;<br />include_once </span><span style="color: #0000BB">$XHPROF_ROOT </span><span style="color: #007700">. </span><span style="color: #DD0000">"/xhprof_lib/utils/xhprof_lib.php"</span><span style="color: #007700">;<br />include_once </span><span style="color: #0000BB">$XHPROF_ROOT </span><span style="color: #007700">. </span><span style="color: #DD0000">"/xhprof_lib/utils/xhprof_runs.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$xhprof_runs </span><span style="color: #007700">= new </span><span style="color: #0000BB">XHProfRuns_Default</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$run_id </span><span style="color: #007700">= </span><span style="color: #0000BB">$xhprof_runs</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">save_run</span><span style="color: #007700">(</span><span style="color: #0000BB">$xhprof_data</span><span style="color: #007700">, </span><span style="color: #DD0000">"xhprof_testing"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"http://localhost/xhprof/xhprof_html/index.php?run=</span><span style="color: #007700">{</span><span style="color: #0000BB">$run_id</span><span style="color: #007700">}</span><span style="color: #DD0000">&amp;source=xhprof_testing\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
  </div>

  <div class="example-contents"><p>O exemplo acima produzirá
algo semelhante a:</p></div>
  <div class="example-contents screen">
<div class="cdata"><pre>
http://localhost/xhprof/xhprof_html/index.php?run=t11_4bdf44d21121f&amp;source=xhprof_testing
</pre></div>
  </div>
 </div>
</div>
<?php manual_footer($setup); ?>