Esempio n. 1
0
function parseXMLFile($fileInfo, &$memoryLeakData)
{
    usleep($fileInfo['time'] * 1000000 / 2);
    consumeMemory($fileInfo['size'] * 10, $memoryLeakData);
}
function storeData($fileInfo, &$memoryLeakData)
{
    // pm is shortcut for ProcessMonitor::dump()
    pm('some debug msg');
    usleep($fileInfo['time'] * 1000000 / 3);
    consumeMemory($fileInfo['size'] / 10, $memoryLeakData);
}
// end of fake demo specific code
// processMonitor extends Tracy\Debugger and mostly respects it's configuration
// therefore configure Debugger first
Debugger::detectDebugMode();
Debugger::enable();
Debugger::$maxDepth = 1;
// initialize ProcessMonitor
ProcessMonitor::$reportMode = ProcessMonitor::SHOW_DETAIL;
// ProcessMonitor::start is intended to be run only once
ProcessMonitor::start('some API import (this is only fake demo)');
$count = 0;
// this is how typical processing loop looks like
foreach ($filesList as $fileInfo) {
    // while debugging scripts which repeat some actions multiple times
    // reset process monitor timers in each loop
    pmr('some api call to import ' . $fileInfo['name']);
    // 1. step some api call
    runApiCallToGetXMLFile($fileInfo, $memoryLeakData);
    // pms is shortcut for ProcessMonitor::addSummary()