<code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* PROFILE for script example.php */<br />/* created 05/22/04 14:32:53 */<br /></span><span style="color: #0000BB">?><br /><?php
<br /> </span><span style="color: #007700">include_once(</span><span style="color: #DD0000">'class.solace.profiler.php'</span><span style="color: #007700">);
<br /></span><span style="color: #FF8000">/* 2 00.72% */ </span><span style="color: #007700">declare(</span><span style="color: #0000BB">ticks</span><span style="color: #007700">=</span><span style="color: #0000BB">1</span><span style="color: #007700">);
<br /></span><span style="color: #FF8000">/* 1 00.08% */ </span><span style="color: #007700">include(</span><span style="color: #DD0000">'example_include.php'</span><span style="color: #007700">);
<br />
<br /> </span><span style="color: #FF8000">// This example does nothing, just a demonstration
<br />
<br />/* 1 00.08% */ </span><span style="color: #0000BB">$a </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">; </span><span style="color: #FF8000">// direct assignment is the fastest operation
<br />/* 1 00.08% */ </span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">20</span><span style="color: #007700">;
<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">< </span><span style="color: #0000BB">100</span><span style="color: #007700">; </span><span style="color: #0000BB">$i</span><span style="color: #007700">++) { </span><span style="color: #FF8000">// 'for' is counted at the ending '}'
<br />/* 100 07.45% */ </span><span style="color: #0000BB">$a </span><span style="color: #007700">= </span><span style="color: #0000BB">$a</span><span style="color: #007700">; </span><span style="color: #FF8000">// dummy, just to compare speed
<br />/* 100 07.33% */ </span><span style="color: #0000BB">$aa </span><span style="color: #007700">= &</span><span style="color: #0000BB">$a</span><span style="color: #007700">; </span><span style="color: #FF8000">// assigning and referencing takes the same time
<br />/* 100 07.37% */ </span><span style="color: #0000BB">$a</span><span style="color: #007700">++;
<br /></span><span style="color: #FF8000">/* 100 08.25% */ </span><span style="color: #0000BB">$b </span><span style="color: #007700">+= </span><span style="color: #0000BB">1</span><span style="color: #007700">; </span><span style="color: #FF8000">// this is usually a bit slower then $a++ (at least on my slow test PC)
<br />/* 100 25.81% */ </span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">); </span><span style="color: #FF8000">// the main time-eater
<br /> </span><span style="color: #007700">if (</span><span style="color: #0000BB">$c</span><span style="color: #007700">) { </span><span style="color: #FF8000">// 'if' is counted at the ending '}'
<br />/* 40 04.44% */ </span><span style="color: #0000BB">$f </span><span style="color: #007700">= @</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">);
<br /></span><span style="color: #FF8000">/* 40 03.21% */ </span><span style="color: #007700">if (</span><span style="color: #0000BB">$f</span><span style="color: #007700">) </span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$f</span><span style="color: #007700">); </span><span style="color: #FF8000">// closing is faster then opening
<br />/* 80 06.04% */ </span><span style="color: #0000BB">$b</span><span style="color: #007700">++;
<br /></span><span style="color: #FF8000">/* 40 02.90% */ </span><span style="color: #007700">}
<br /> else </span><span style="color: #FF8000">// 'else' is counted at the ending '}'
<br /> </span><span style="color: #007700">{
<br /></span><span style="color: #FF8000">/* 60 04.41% */ </span><span style="color: #0000BB">$a</span><span style="color: #007700">++;
<br /></span><span style="color: #FF8000">/* 160 12.06% */ </span><span style="color: #007700">} </span><span style="color: #FF8000">// this line shows 160 (summary of 'else' and overall 'if' passes)
<br />/* 101 09.76% */ </span><span style="color: #007700">} </span><span style="color: #FF8000">// 101 = 100 cycles + 1 initial php parser pass
<br />
<br /></span><span style="color: #0000BB">?>
<br /></span>
</span>
</code><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* PROFILE for script example_include.php */<br />/* created 05/22/04 14:32:53 */<br /></span><span style="color: #0000BB">?><br /><?php
<br />
<br /> </span><span style="color: #007700">function </span><span style="color: #0000BB">test</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">, </span><span style="color: #0000BB">$b</span><span style="color: #007700">) </span><span style="color: #FF8000">// declarations are not counted (no tick)
<br /> </span><span style="color: #007700">{
<br /></span><span style="color: #FF8000">/* 100 97.66% */ </span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">$a </span><span style="color: #007700">- </span><span style="color: #0000BB">$b</span><span style="color: #007700">; </span><span style="color: #FF8000">// 100 cycles
<br /> </span><span style="color: #007700">return </span><span style="color: #0000BB">$c </span><span style="color: #007700">> </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'return' doesn't produce a tick, so it is ignored
<br />/* 1 01.26% */ </span><span style="color: #007700">} </span><span style="color: #FF8000">// 1 initial php parser pass
<br />
<br /></span><span style="color: #0000BB">?>
<br /></span>
</span>
</code> |