コード例 #1
0
 static function setUpColumns($columns)
 {
     $columns->symbolId = Symbol::columns()->id;
     $columns->runId = Run::columns()->id;
     $columns->isInclusive = Column::INTEGER;
     parent::setUpColumns($columns);
 }
コード例 #2
0
 static function setUpColumns($columns)
 {
     $columns->parentSymbolId = Symbol::columns()->id;
     $columns->childSymbolId = Symbol::columns()->id;
     $columns->runId = Run::columns()->id;
     parent::setUpColumns($columns);
 }
コード例 #3
0
ファイル: Compare.php プロジェクト: phperf/xhprof-analytics
 public function addRun($runName)
 {
     if (!array_key_exists($runName, $this->runs)) {
         $run = Run::statement()->select('*')->where('? = ?', Run::columns()->name, $runName)->query()->fetchRow();
         $this->runs[$runName] = $run;
         $this->runIds[] = Run::cast($run)->id;
     }
 }
コード例 #4
0
 public function showSymbol()
 {
     if (!empty($_GET['run'])) {
         $run = new Run();
         $run->name = $_GET['run'];
         $run->findSaved()->id;
         $this->runName = $run->findSaved()->id;
     }
     /** @var Symbol $symbol */
     $symbol = Symbol::statement()->where('? = ?', Symbol::columns()->name, $this->symbol)->query()->fetchRow();
     if (null === $symbol) {
         return $this->error('Symbol ? not found', $this->symbol);
     }
     $stack = new Stack();
     $database = Database::getInstance();
     $inc = RelatedStat::columns();
     $mainSymbol = new Symbol();
     $mainSymbol->name = 'main()';
     $mainSymbol->findOrSave();
     $total_wt = $database->select(Run::table())->select("SUM(?) AS total_wt", Run::columns()->wallTime)->query()->fetchRow('total_wt');
     $stack->push(Raw::create('<h2>Total: ' . $total_wt . '</h2>'));
     $statement = $database->select(RelatedStat::table())->select("SUM(?)/1000000 AS total_wt, SUM(?) AS total_ct, COUNT(DISTINCT ?) AS runs, ? AS symbol_id, ?", $inc->wallTime, $inc->calls, $inc->runId, $inc->parentSymbolId, Symbol::columns()->name)->leftJoin('? ON ? = ?', Symbol::table(), Symbol::columns()->id, $inc->parentSymbolId)->where('? = ?', $inc->childSymbolId, $symbol->id)->groupBy($inc->parentSymbolId)->order('total_wt DESC')->limit(50);
     $res = $statement->query();
     $table = new HTML();
     $stack->push(Raw::create('<h2>Parents</h2>'));
     $stack->push($table);
     foreach ($res as $row) {
         $row['percent'] = round(100 * $row['total_wt'] / $total_wt, 2);
         $row['name'] = '<a href="?symbol=' . urlencode($row['name']) . '&run=' . $_GET['run'] . '">' . $row['name'] . '</a>';
         unset($row['symbol_id']);
         $table->addRow($row);
     }
     $statement = $database->select(RelatedStat::table())->select("SUM(?)/1000000 AS total_wt, SUM(?) AS total_ct, COUNT(DISTINCT ?) AS runs, ? AS symbol_id, ?", $inc->wallTime, $inc->calls, $inc->runId, $inc->childSymbolId, Symbol::columns()->name)->leftJoin('? ON ? = ?', Symbol::table(), Symbol::columns()->id, $inc->childSymbolId)->where('? = ?', $inc->parentSymbolId, $symbol->id)->groupBy($inc->childSymbolId)->order('total_wt DESC')->limit(50);
     $res = $statement->query();
     $table = new HTML();
     $stack->push(Raw::create('<h2>Children</h2>'));
     $stack->push($table);
     foreach ($res as $row) {
         $row['percent'] = round(100 * $row['total_wt'] / $total_wt, 2);
         $row['name'] = '<a href="?symbol=' . urlencode($row['name']) . '&run=' . $_GET['run'] . '">' . $row['name'] . '</a>';
         unset($row['symbol_id']);
         $table->addRow($row);
     }
     $this->layout->setTitle($symbol->name)->pushMain($stack)->render();
 }
コード例 #5
0
ファイル: Aggregate.php プロジェクト: phperf/xhprof-analytics
 /**
  * Required setup column types in provided columns object
  * @param $columns static|\stdClass
  */
 static function setUpColumns($columns)
 {
     $columns->id = Column::AUTO_ID;
     $columns->runId = Run::columns()->id;
     $columns->tagGroupId = TagGroup::columns()->id;
     $columns->period = Column::INTEGER + Column::NOT_NULL;
     $columns->utFrom = Column::INTEGER + Column::TIMESTAMP;
     $columns->utTo = Column::INTEGER + Column::TIMESTAMP;
 }
コード例 #6
0
 public function run(Log $log = null)
 {
     /** @var \Yaoi\Database\Definition\Table[] $tables */
     $tables = array(Symbol::table(), Run::table(), RelatedStat::table(), SymbolStat::table(), Project::table(), Tag::table(), Aggregate::table(), ReportAggregate::table(), TagGroup::table());
     if (null === $log) {
         $log = Log::nil();
     }
     foreach ($tables as $table) {
         $table->migration()->setLog($log)->apply();
     }
 }
コード例 #7
0
ファイル: Import.php プロジェクト: phperf/xhprof-analytics
 public function addRun($xhprofData, Run $run = null)
 {
     if (!$xhprofData) {
         return;
     }
     //Database::getInstance()->log(new Log('stdout'));
     if (null === $run) {
         $run = new Run();
         $run->ut = time();
     }
     $this->run = $run;
     $run->addXhSample($xhprofData['main()']);
     $run->save();
     $this->getStat($this->getSymbol('main()'), false)->addXhSample($xhprofData['main()']);
     $totalInclusive = $this->getStat($this->getSymbol('TOTAL'), false);
     foreach ($xhprofData as $key => $value) {
         if ('main()' === $key) {
             continue;
         }
         $this->lastSample = $value;
         $symbolNames = explode('==>', $key);
         $parentSymbol = $this->getSymbol($symbolNames[0]);
         $childSymbol = $this->getSymbol($symbolNames[1]);
         $totalInclusive->addXhSample($value, 'main()' === $parentSymbol->name);
         // add time only for level 1 calls
         $this->getRelatedStat($parentSymbol, $childSymbol)->addXhSample($value);
         $this->getStat($parentSymbol)->subXhSample($value);
         $this->getStat($childSymbol)->addXhSample($value);
         $this->getStat($childSymbol, false)->addXhSample($value);
         unset($parentSymbol, $childSymbol);
     }
     //$batchSaver->flush();
     $this->runInstance->runs++;
     if ($this->noSquash) {
         $this->saveRelatedStats();
         $this->saveSymbolStats();
     }
 }
コード例 #8
0
ファイル: Import.php プロジェクト: phperf/xhprof-analytics
 public function addRun($xhprofData, Run $run = null)
 {
     if (!$xhprofData) {
         return;
     }
     //Database::getInstance()->log(new Log('stdout'));
     if (null === $run) {
         $run = new Run();
         $run->ut = time();
     }
     $this->run = $run;
     $this->symbolStats = array();
     $batchSaver = new BatchSaver();
     $batchSaver->pageSize = 1000;
     $run->addXhSample($xhprofData['main()']);
     $run->save();
     $this->getStat($this->getSymbol('main()'));
     //->addXhSample($xhprofData['main()']);
     $totalWallTime = 0;
     $totalCount = 0;
     foreach ($xhprofData as $key => $value) {
         if ('main()' === $key) {
             continue;
         }
         $this->lastSample = $value;
         $symbolNames = explode('==>', $key);
         $parentSymbol = $this->getSymbol($symbolNames[0]);
         $childSymbol = $this->getSymbol($symbolNames[1]);
         if ('main()' === $parentSymbol->name) {
             $totalWallTime += $value['wt'];
         }
         $totalCount += $value['ct'];
         /*
         $relatedStat = new RelatedStat();
         $relatedStat->runId = $run->id;
         $relatedStat->parentSymbolId = $parentSymbol->id;
         $relatedStat->childSymbolId = $childSymbol->id;
         $relatedStat->addXhSample($value);
         */
         $this->getStat($parentSymbol)->subXhSample($value);
         $this->getStat($childSymbol)->addXhSample($value);
         $this->getStat($childSymbol, false)->addXhSample($value);
         //$batchSaver->add($relatedStat);
         //$relatedStat->save();
         unset($parentSymbol, $childSymbol);
     }
     $this->getStat($this->getSymbol('main()'))->wallTime = $totalWallTime;
     $this->getStat($this->getSymbol('main()'))->calls = $totalCount;
     //$batchSaver->flush();
     $batchSaver = new BatchSaver();
     $batchSaver->pageSize = 1000;
     foreach ($this->symbolStats as $stat) {
         $batchSaver->add($stat);
     }
     $batchSaver->flush();
     /*
     $columns = SymbolStat::columns();
     Database::getInstance()
         ->update(SymbolStat::table()->schemaName)
         ->set('? = ? / ?, ? = ? / ?',
             $columns->wallTimePart,
             $columns->wallTime,
             $totalWallTime,
             $columns->countPart,
             $columns->count,
             $totalCount
         )
         ->where('? = ?', $columns->runId, $run->id)->query()->execute();
     */
     //die();
     $this->groupRun->wallTime += $totalWallTime;
     $this->groupRun->runs++;
     $this->groupRun->save();
 }