<?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 => 'ru',
  ),
  'this' => 
  array (
    0 => 'xhprof.examples.php',
    1 => 'Примеры',
    2 => 'Примеры',
  ),
  'up' => 
  array (
    0 => 'book.xhprof.php',
    1 => 'Xhprof',
  ),
  'prev' => 
  array (
    0 => 'xhprof.constants.php',
    1 => 'Предопределённые константы',
  ),
  'next' => 
  array (
    0 => 'ref.xhprof.php',
    1 => 'Функции Xhprof',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    '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">Примеры</h1>

 <div class="example" id="example-1">
  <p><strong>Пример #1 Примеры использования Xhprof, опционально с GUI</strong></p>
  <div class="example-contents"><p>
   В этом примере профайлер запускается, останавливается и использует
   встроенный GUI интерфейс для сохранения и разбора результатов.
   Другими словами, исполнение кода модуля завершается
   на функции <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>
 Вывод приведённого примера будет похож на:
</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); ?>