<?php
// It is only line to activate UltimaPHP debugger
require_once('udebug.class.php');
// Lets here is ordinary program with delays, loops and so
// NOTE: Remove or comment out "uDebug::..." lines after debugging !
uDebug::openMarker('main');
$zoo = array();
for ($i = 0; $i < 20; $i ++) {
uDebug::openMarker('wild_cat', $i);
$legs = 0;
for ($w = 0; $w < 10000; $w ++) {
$legs += (2 * 2); // 4 legs of each cat
}
$zoo['wild_cats'][] = $legs / 10000;
uDebug::closeMarker();
uDebug::openMarker('wild_goose', $i);
$legs = 0;
for ($w = 0; $w < 10000; $w ++) {
$legs += (2 * 1); // 2 legs of each goose
}
$zoo['wild_goose'][] = $legs / 10000;
if ($i % 6 == 0) {
// Goose with broken leg
// Bring him to animal hospital
uDebug::openMarker('wild_goose_hospital', $i);
$health = 0;
for ($z = 0; $z < 25000; $z ++) {
$health += 0.78;
}
uDebug::closeMarker();
}
uDebug::closeMarker();
}
print_r($zoo);
uDebug::closeMarker();
// Print debug reports
$xml = uDebug::report_XML();
echo "<pre>\n";
echo "Debug info:\n";
echo htmlentities(uDebug::indentedXML($xml->asXML()));
// Count time only for wild gooses
$xp = $xml->xpath('//n[@name="wild_goose"]');
$ts = 0;
foreach ($xp as $d) {
$ts += (float)$d['t'];
}
echo "\n\nTotal time for wild gooses = ".$ts;
// Count time only for wild cats
$xp = $xml->xpath('//n[@name="wild_cat"]');
$ts = 0;
foreach ($xp as $d) {
$ts += (float)$d['t'];
}
echo "\n\nTotal time for wild cats = ".$ts;
echo "</pre>";
// In the report you can see time got to each animal (attribute "t") and also
// time got to health gooses with broken legs (so total time for that gooses increases, you can see it)
|