souffle  2.0.2-371-g6315b36
Public Member Functions | Private Attributes
souffle::profile::OutputProcessor Class Reference

#include <OutputProcessor.h>

Collaboration diagram for souffle::profile::OutputProcessor:
Collaboration graph

Public Member Functions

Table getAtomTable (std::string strRel, std::string strRul) const
 
const std::shared_ptr< ProgramRun > & getProgramRun () const
 
Table getRelTable () const
 
Table getRulTable () const
 
Table getSubrulTable (std::string strRel, std::string strRul) const
 
Table getVersionAtoms (std::string strRel, std::string strRul, int version) const
 
Table getVersions (std::string strRel, std::string strRul) const
 
 OutputProcessor ()
 

Private Attributes

std::shared_ptr< ProgramRunprogramRun
 

Detailed Description

Definition at line 34 of file OutputProcessor.h.

Constructor & Destructor Documentation

◆ OutputProcessor()

souffle::profile::OutputProcessor::OutputProcessor ( )
inline

Definition at line 39 of file OutputProcessor.h.

39  {
40  programRun = std::make_shared<ProgramRun>(ProgramRun());
41  }

References programRun.

Member Function Documentation

◆ getAtomTable()

Table souffle::profile::OutputProcessor::getAtomTable ( std::string  strRel,
std::string  strRul 
) const
inline

Definition at line 199 of file OutputProcessor.h.

199  {
200  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
201  programRun->getRelationMap();
202 
203  Table table;
204  for (auto& current : relationMap) {
205  std::shared_ptr<Relation> rel = current.second;
206 
207  if (rel->getId() != strRel) {
208  continue;
209  }
210 
211  for (auto& current : rel->getRuleMap()) {
212  std::shared_ptr<Rule> rule = current.second;
213  if (rule->getId() != strRul) {
214  continue;
215  }
216  for (auto& atom : rule->getAtoms()) {
217  Row row(4);
218  row[0] = std::make_shared<Cell<std::string>>(atom.rule);
219  row[1] = std::make_shared<Cell<std::string>>(atom.identifier);
220  row[2] = std::make_shared<Cell<long>>(atom.level);
221  row[3] = std::make_shared<Cell<long>>(atom.frequency);
222 
223  table.addRow(std::make_shared<Row>(row));
224  }
225  }
226  }
227  return table;
228 }

References souffle::profile::Table::addRow(), programRun, rel(), and rule.

Referenced by verRul().

Here is the call graph for this function:

◆ getProgramRun()

const std::shared_ptr<ProgramRun>& souffle::profile::OutputProcessor::getProgramRun ( ) const
inline

◆ getRelTable()

Table souffle::profile::OutputProcessor::getRelTable ( ) const
inline

Definition at line 77 of file OutputProcessor.h.

77  {
78  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
79  programRun->getRelationMap();
80  Table table;
81  for (auto& rel : relationMap) {
82  std::shared_ptr<Relation> r = rel.second;
83  Row row(13);
84  auto total_time = r->getNonRecTime() + r->getRecTime() + r->getCopyTime();
85  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(total_time);
86  row[1] = std::make_shared<Cell<std::chrono::microseconds>>(r->getNonRecTime());
87  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(r->getRecTime());
88  row[3] = std::make_shared<Cell<std::chrono::microseconds>>(r->getCopyTime());
89  row[4] = std::make_shared<Cell<long>>(r->size());
90  row[5] = std::make_shared<Cell<std::string>>(r->getName());
91  row[6] = std::make_shared<Cell<std::string>>(r->getId());
92  row[7] = std::make_shared<Cell<std::string>>(r->getLocator());
93  if (total_time.count() != 0) {
94  row[8] = std::make_shared<Cell<long>>(r->size() / (total_time.count() / 1000000.0));
95  } else {
96  row[8] = std::make_shared<Cell<long>>(r->size());
97  }
98  row[9] = std::make_shared<Cell<std::chrono::microseconds>>(r->getLoadtime());
99  row[10] = std::make_shared<Cell<std::chrono::microseconds>>(r->getSavetime());
100  row[11] = std::make_shared<Cell<long>>(r->getMaxRSSDiff());
101  row[12] = std::make_shared<Cell<long>>(r->getReads());
102 
103  table.addRow(std::make_shared<Row>(row));
104  }
105  return table;
106 }

References souffle::profile::Table::addRow(), programRun, and rel().

Referenced by souffle::profile::Tui::runCommand(), and updateDB().

Here is the call graph for this function:

◆ getRulTable()

Table souffle::profile::OutputProcessor::getRulTable ( ) const
inline

Definition at line 121 of file OutputProcessor.h.

121  {
122  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
123  programRun->getRelationMap();
124  std::unordered_map<std::string, std::shared_ptr<Row>> ruleMap;
125 
126  for (auto& rel : relationMap) {
127  for (auto& current : rel.second->getRuleMap()) {
128  Row row(11);
129  std::shared_ptr<Rule> rule = current.second;
130  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
131  row[1] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
132  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
133  row[3] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
134  row[4] = std::make_shared<Cell<long>>(rule->size());
135  row[5] = std::make_shared<Cell<std::string>>(rule->getName());
136  row[6] = std::make_shared<Cell<std::string>>(rule->getId());
137  row[7] = std::make_shared<Cell<std::string>>(rel.second->getName());
138  row[8] = std::make_shared<Cell<long>>(0);
139  row[10] = std::make_shared<Cell<std::string>>(rule->getLocator());
140  ruleMap.emplace(rule->getName(), std::make_shared<Row>(row));
141  }
142  for (auto& iter : rel.second->getIterations()) {
143  for (auto& current : iter->getRules()) {
144  std::shared_ptr<Rule> rule = current.second;
145  if (ruleMap.find(rule->getName()) != ruleMap.end()) {
146  Row row = *ruleMap[rule->getName()];
147  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(
148  row[2]->getTimeVal() + rule->getRuntime());
149  row[4] = std::make_shared<Cell<long>>(row[4]->getLongVal() + rule->size());
150  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(
151  row[0]->getTimeVal() + rule->getRuntime());
152  ruleMap[rule->getName()] = std::make_shared<Row>(row);
153  } else {
154  Row row(11);
155  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
156  row[1] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
157  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
158  row[3] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
159  row[4] = std::make_shared<Cell<long>>(rule->size());
160  row[5] = std::make_shared<Cell<std::string>>(rule->getName());
161  row[6] = std::make_shared<Cell<std::string>>(rule->getId());
162  row[7] = std::make_shared<Cell<std::string>>(rel.second->getName());
163  row[8] = std::make_shared<Cell<long>>(rule->getVersion());
164  row[10] = std::make_shared<Cell<std::string>>(rule->getLocator());
165  ruleMap[rule->getName()] = std::make_shared<Row>(row);
166  }
167  }
168  }
169  for (auto& current : ruleMap) {
170  std::shared_ptr<Row> row = current.second;
171  Row t = *row;
172  std::chrono::microseconds val = t[1]->getTimeVal() + t[2]->getTimeVal() + t[3]->getTimeVal();
173 
174  t[0] = std::make_shared<Cell<std::chrono::microseconds>>(val);
175 
176  if (t[0]->getTimeVal().count() != 0) {
177  t[9] = std::make_shared<Cell<double>>(t[4]->getLongVal() / (t[0]->getDoubleVal() * 1000));
178  } else {
179  t[9] = std::make_shared<Cell<double>>(t[4]->getLongVal() / 1.0);
180  }
181  current.second = std::make_shared<Row>(t);
182  }
183  }
184 
185  Table table;
186  for (auto& current : ruleMap) {
187  table.addRow(current.second);
188  }
189  return table;
190 }

References souffle::profile::Table::addRow(), programRun, rel(), and rule.

Referenced by souffle::profile::Tui::runCommand(), and updateDB().

Here is the call graph for this function:

◆ getSubrulTable()

Table souffle::profile::OutputProcessor::getSubrulTable ( std::string  strRel,
std::string  strRul 
) const
inline

Definition at line 234 of file OutputProcessor.h.

234  {
235  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
236  programRun->getRelationMap();
237 
238  Table table;
239  for (auto& current : relationMap) {
240  std::shared_ptr<Relation> rel = current.second;
241 
242  if (rel->getId() != strRel) {
243  continue;
244  }
245 
246  for (auto& current : rel->getRuleMap()) {
247  std::shared_ptr<Rule> rule = current.second;
248  if (rule->getId() != strRul) {
249  continue;
250  }
251  for (auto& atom : rule->getAtoms()) {
252  Row row(1);
253  row[0] = std::make_shared<Cell<std::string>>(atom.rule);
254 
255  table.addRow(std::make_shared<Row>(row));
256  }
257  }
258  }
259  return table;
260 }

References souffle::profile::Table::addRow(), programRun, rel(), and rule.

Here is the call graph for this function:

◆ getVersionAtoms()

Table souffle::profile::OutputProcessor::getVersionAtoms ( std::string  strRel,
std::string  strRul,
int  version 
) const
inline

Definition at line 345 of file OutputProcessor.h.

345  {
346  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
347  programRun->getRelationMap();
348  Table table;
349  std::shared_ptr<Relation> rel;
350 
351  for (auto& current : relationMap) {
352  if (current.second->getId() == strRel) {
353  rel = current.second;
354  break;
355  }
356  }
357  if (rel == nullptr) {
358  return table;
359  }
360 
361  for (auto& iter : rel->getIterations()) {
362  for (auto& current : iter->getRules()) {
363  std::shared_ptr<Rule> rule = current.second;
364  if (rule->getLocator() == srcLocator && rule->getVersion() == version) {
365  for (auto& atom : rule->getAtoms()) {
366  Row row(4);
367  row[0] = std::make_shared<Cell<std::string>>(atom.rule);
368  row[1] = std::make_shared<Cell<std::string>>(atom.identifier);
369  row[2] = std::make_shared<Cell<long>>(atom.level);
370  row[3] = std::make_shared<Cell<long>>(atom.frequency);
371  table.addRow(std::make_shared<Row>(row));
372  }
373  }
374  }
375  }
376 
377  return table;
378 }

References souffle::profile::Table::addRow(), programRun, rel(), and rule.

Referenced by verRul().

Here is the call graph for this function:

◆ getVersions()

Table souffle::profile::OutputProcessor::getVersions ( std::string  strRel,
std::string  strRul 
) const
inline

Definition at line 276 of file OutputProcessor.h.

276  {
277  const std::unordered_map<std::string, std::shared_ptr<Relation>>& relationMap =
278  programRun->getRelationMap();
279  Table table;
280 
281  std::shared_ptr<Relation> rel;
282  for (auto& current : relationMap) {
283  if (current.second->getId() == strRel) {
284  rel = current.second;
285  break;
286  }
287  }
288  if (rel == nullptr) {
289  return table;
290  }
291 
292  std::unordered_map<std::string, std::shared_ptr<Row>> ruleMap;
293  for (auto& iter : rel->getIterations()) {
294  for (auto& current : iter->getRules()) {
295  std::shared_ptr<Rule> rule = current.second;
296  if (rule->getId() == strRul) {
297  std::string strTemp =
298  rule->getName() + rule->getLocator() + std::to_string(rule->getVersion());
299 
300  if (ruleMap.find(strTemp) != ruleMap.end()) {
301  Row row = *ruleMap[strTemp];
302  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(
303  row[2]->getTimeVal() + rule->getRuntime());
304  row[4] = std::make_shared<Cell<long>>(row[4]->getLongVal() + rule->size());
305  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
306  ruleMap[strTemp] = std::make_shared<Row>(row);
307  } else {
308  Row row(10);
309  row[1] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
310  row[2] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
311  row[3] = std::make_shared<Cell<std::chrono::microseconds>>(std::chrono::microseconds(0));
312  row[4] = std::make_shared<Cell<long>>(rule->size());
313  row[5] = std::make_shared<Cell<std::string>>(rule->getName());
314  row[6] = std::make_shared<Cell<std::string>>(rule->getId());
315  row[7] = std::make_shared<Cell<std::string>>(rel->getName());
316  row[8] = std::make_shared<Cell<long>>(rule->getVersion());
317  row[9] = std::make_shared<Cell<std::string>>(rule->getLocator());
318  row[0] = std::make_shared<Cell<std::chrono::microseconds>>(rule->getRuntime());
319  ruleMap[strTemp] = std::make_shared<Row>(row);
320  }
321  }
322  }
323  }
324 
325  for (auto row : ruleMap) {
326  Row t = *row.second;
327  t[0] = std::make_shared<Cell<std::chrono::microseconds>>(
328  t[1]->getTimeVal() + t[2]->getTimeVal() + t[3]->getTimeVal());
329  ruleMap[row.first] = std::make_shared<Row>(t);
330  }
331 
332  for (auto& current : ruleMap) {
333  table.addRow(current.second);
334  }
335  return table;
336 }

References souffle::profile::Table::addRow(), programRun, rel(), and rule.

Referenced by souffle::genJsonRules(), verGraph(), and verRul().

Here is the call graph for this function:

Field Documentation

◆ programRun

std::shared_ptr<ProgramRun> souffle::profile::OutputProcessor::programRun
private

The documentation for this class was generated from the following file:
souffle::profile::OutputProcessor::programRun
std::shared_ptr< ProgramRun > programRun
Definition: OutputProcessor.h:36
rule
Rule & rule
Definition: Reader.h:85
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086