26.02.2015 Views

Optimasi dan Performansi Aplikasi Web php.pdf

Optimasi dan Performansi Aplikasi Web php.pdf

Optimasi dan Performansi Aplikasi Web php.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tips <strong>dan</strong> Trik IlmuKomputer.Com<br />

Copyright ©2003-2006 IlmuKomputer.Com<br />

}<br />

$copy = $timing;<br />

foreach ($copy as $label => $time1) {<br />

echo '', $label, '';<br />

printf("%.3f seconds\n", $time1);<br />

foreach ($timing as $label2 => $time2) {<br />

$percent = (($time2 / $time1) - 1) * 100;<br />

if ($percent > 0) {<br />

printf("%.3f seconds %.1f%% slower", $time2, $percent);<br />

} elseif ($percent < 0) {<br />

printf("%.3f seconds %.1f%% faster", $time2, -$percent);<br />

} else { // sama dengan 0<br />

echo ' -';<br />

}<br />

echo '';<br />

}<br />

echo '';<br />

}<br />

echo '';<br />

// Get current time (format Unix)<br />

function currTime() {<br />

list($usec, $sec) = explode(' ', microtime());<br />

return ((float)$usec + (float)$sec);<br />

}<br />

?><br />

Cara menggunakan kode profiler di atas seperti berikut:<br />

<br />

Hasil dari pengujian kurang lebih akan terlihat seperti Gambar 2.<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!