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(); } }
public function listTop() { $database = Database::getInstance(); $esc = SymbolStat::columns(); $statement = $database->select(SymbolStat::table())->select("SUM(?) AS total_wt, SUM(?) AS total_ct, COUNT(DISTINCT ?) AS runs, ?, ?", $esc->wallTime, $esc->calls, $esc->runId, $esc->symbolId, Symbol::columns()->name)->leftJoin('? ON ? = ?', Symbol::table(), Symbol::columns()->id, $esc->symbolId)->groupBy(SymbolStat::columns()->symbolId)->order('total_wt DESC')->limit(50); $res = $statement->query(); $table = new HTML(); foreach ($res as $row) { $row['name'] = '<a href="?symbol=' . urlencode($row['name']) . '">' . $row['name'] . '</a>'; unset($row['symbol_id']); $table->addRow($row); } $this->layout->pushMain($table)->render(); }
/** * @return $this|\Yaoi\Sql\SelectInterface|\Yaoi\Sql\UpdateInterface */ public function build($statExpr) { $symbolsDerived = SymbolStat::table('s'); $symbolsDerivedCols = SymbolStat::columns($symbolsDerived); $symbolCols = Symbol::columns(); $this->expr = Database::getInstance()->statement()->select('? AS ?', $symbolCols->name, new S('function'))->from('? AS s', $statExpr)->leftJoin('? ON ? = ?', Symbol::table(), $symbolsDerivedCols->symbolId, $symbolCols->id)->groupBy('?', $symbolsDerivedCols->symbolId); $this->avgWtSymbols = array(); foreach ($this->runs as $run) { $runXTable = SymbolStat::table($run->name); $runXCols = SymbolStat::columns($runXTable); $this->addColumns($run, $runXCols); $this->expr->leftJoin('? ON ? = ? AND ? = ? AND ? = ?', $runXTable, $runXCols->symbolId, $symbolsDerivedCols->symbolId, $runXCols->isInclusive, $this->isInclusive, $runXCols->runId, $run->id); } $outerExpr = Database::getInstance()->statement()->select('*')->from('? AS ss', $this->expr)->order('COALESCE(null, ?) DESC', array($this->avgWtSymbols))->limit($this->limit); return $outerExpr; }