/** * {@inheritdoc} */ public function analyse() { parent::analyse(); list($peak, $call, $file, $line) = $this->parse(); $memory = Format::bytes($peak); $details = null; if ($call) { $details = ' at ' . $call . '() in ' . $file . ' on line ' . $line; } $report = $this->createReport(); $report->setText('Memory peak ' . $memory . $details); return $report; }
/** * {@inheritdoc} */ public function analyse() { parent::analyse(); // calculate critical path $this->parse(); $critical = array(); $this->extract($this->tree, $critical); $report = $this->createReport(); $root = reset($critical); $time = Format::time($root['time']); $report->setTitle("Critical path ({$time})"); $report->addRow(array('', 'Call', 'Time', 'Memory', 'File', 'Line', '')); foreach ($critical as $position => $call) { $name = str_repeat('.', $position) . ' ' . $call['name'] . '()'; $type = $call['is-internal'] ? 'internal' : 'user defined'; $report->addRow(array((string) $position, trim($name), Format::time($call['time']), Format::bytes($call['memory']), $call['file'], $call['line'], $type)); } return $report; }
/** * {@inheritdoc} */ public function analyse() { parent::analyse(); $this->parse(); $calls = array_slice($this->getSortedCalls('memory-own'), 0, 5); $report = $this->createReport(); $report->setTitle('Top memory usage calls'); $report->addRow(array('', 'Call', '# of Calls', 'Own Memory', 'Including Children', '')); $position = 0; foreach ($calls as $name => $call) { if ($call['is-internal']) { $type = 'internal'; $inclusive = '-'; } else { $type = 'user defined'; $inclusive = Format::bytes($call['memory-inclusive']); } $report->addRow(array((string) $position++, $name . '()', (string) $call['times'], Format::bytes($call['memory-own']), $inclusive, $type)); } return $report; }
/** * @dataProvider providerBytes * @covers Telltale\Util\Format::bytes */ public function testBytes($bytes, $expected) { $this->assertEquals($expected, Format::bytes($bytes)); }