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

#include <Relation.h>

Collaboration diagram for souffle::profile::Relation:
Collaboration graph

Public Member Functions

void addIteration (std::shared_ptr< Iteration > iteration)
 
void addReads (size_t tuplesRead)
 
void addRule (std::shared_ptr< Rule > rule)
 
std::string createID ()
 
std::string createRecID (std::string name)
 
std::chrono::microseconds getCopyTime () const
 
std::chrono::microseconds getEndtime () const
 
const std::string & getId () const
 
const std::vector< std::shared_ptr< Iteration > > & getIterations () const
 
std::chrono::microseconds getLoadtime () const
 
const std::string & getLocator () const
 
size_t getMaxRSSDiff () const
 
std::string getName () const
 
std::chrono::microseconds getNonRecTime () const
 
size_t getReads () const
 
std::chrono::microseconds getRecTime () const
 
const std::unordered_map< std::string, std::shared_ptr< Rule > > & getRuleMap () const
 Return a map of Rules, indexed by srcLocator. More...
 
std::vector< std::shared_ptr< Rule > > getRuleRecList () const
 
std::chrono::microseconds getSavetime () const
 
std::chrono::microseconds getStarttime () const
 
size_t getTotalRecursiveRuleSize () const
 
bool isReady ()
 
 Relation (std::string name, std::string id)
 
void setEndtime (std::chrono::microseconds time)
 
void setLoadtime (std::chrono::microseconds loadtime)
 
void setLocator (std::string locator)
 
void setNumTuples (long numTuples)
 
void setPostMaxRSS (size_t maxRSS)
 
void setPreMaxRSS (size_t maxRSS)
 
void setReady (bool ready)
 
void setSavetime (std::chrono::microseconds savetime)
 
void setStarttime (std::chrono::microseconds time)
 
size_t size () const
 
std::string toString () const
 

Private Attributes

std::chrono::microseconds endtime {}
 
const std::string id
 
std::vector< std::shared_ptr< Iteration > > iterations
 
std::chrono::microseconds loadtime {}
 
std::string locator
 
const std::string name
 
long nonRecTuples = 0
 
size_t postMaxRSS = 0
 
size_t preMaxRSS = 0
 
bool ready = true
 
int recursiveId = 0
 
int ruleId = 0
 
std::unordered_map< std::string, std::shared_ptr< Rule > > ruleMap
 
std::chrono::microseconds savetime {}
 
std::chrono::microseconds starttime {}
 
size_t tuplesRead = 0
 

Detailed Description

Definition at line 29 of file Relation.h.

Constructor & Destructor Documentation

◆ Relation()

souffle::profile::Relation::Relation ( std::string  name,
std::string  id 
)
inline

Definition at line 52 of file Relation.h.

52  : name(std::move(name)), id(std::move(id)) {
53  ruleMap = std::unordered_map<std::string, std::shared_ptr<Rule>>();
54  iterations = std::vector<std::shared_ptr<Iteration>>();
55  }

References iterations, and ruleMap.

Member Function Documentation

◆ addIteration()

void souffle::profile::Relation::addIteration ( std::shared_ptr< Iteration iteration)
inline

Definition at line 214 of file Relation.h.

214  {
215  iterations.push_back(iteration);
216  if (endtime < iteration->getEndtime()) {
217  endtime = iteration->getEndtime();
218  }
219  if (starttime.count() == 0 || starttime > iteration->getStarttime()) {
220  starttime = iteration->getStarttime();
221  }
222  }

References endtime, getEndtime(), iteration, iterations, and starttime.

Here is the call graph for this function:

◆ addReads()

void souffle::profile::Relation::addReads ( size_t  tuplesRead)
inline

Definition at line 248 of file Relation.h.

248  {
249  this->tuplesRead += tuplesRead;
250  }

References tuplesRead.

◆ addRule()

void souffle::profile::Relation::addRule ( std::shared_ptr< Rule rule)
inline

Definition at line 196 of file Relation.h.

196  {
197  ruleMap[rule->getLocator()] = rule;
198  }

References rule, and ruleMap.

◆ createID()

std::string souffle::profile::Relation::createID ( )
inline

Definition at line 57 of file Relation.h.

57  {
58  return "N" + id.substr(1) + "." + std::to_string(++ruleId);
59  }

References ruleId.

◆ createRecID()

std::string souffle::profile::Relation::createRecID ( std::string  name)
inline

Definition at line 61 of file Relation.h.

61  {
62  for (auto& iter : iterations) {
63  for (auto& rul : iter->getRules()) {
64  if (rul.second->getName() == name) {
65  return rul.second->getId();
66  }
67  }
68  }
69  return "C" + id.substr(1) + "." + std::to_string(++recursiveId);
70  }

References iterations, name, recursiveId, and rul().

Here is the call graph for this function:

◆ getCopyTime()

std::chrono::microseconds souffle::profile::Relation::getCopyTime ( ) const
inline

Definition at line 100 of file Relation.h.

100  {
101  std::chrono::microseconds result{};
102  for (auto& iter : iterations) {
103  result += iter->getCopytime();
104  }
105  return result;
106  }

References iterations.

◆ getEndtime()

std::chrono::microseconds souffle::profile::Relation::getEndtime ( ) const
inline

Definition at line 84 of file Relation.h.

84  {
85  return endtime;
86  }

References endtime.

Referenced by addIteration().

◆ getId()

const std::string& souffle::profile::Relation::getId ( ) const
inline

Definition at line 224 of file Relation.h.

224  {
225  return id;
226  }

References id.

◆ getIterations()

const std::vector<std::shared_ptr<Iteration> >& souffle::profile::Relation::getIterations ( ) const
inline

Definition at line 210 of file Relation.h.

210  {
211  return iterations;
212  }

References iterations.

◆ getLoadtime()

std::chrono::microseconds souffle::profile::Relation::getLoadtime ( ) const
inline

Definition at line 72 of file Relation.h.

72  {
73  return loadtime;
74  }

References loadtime.

◆ getLocator()

const std::string& souffle::profile::Relation::getLocator ( ) const
inline

Definition at line 228 of file Relation.h.

228  {
229  return locator;
230  }

References locator.

◆ getMaxRSSDiff()

size_t souffle::profile::Relation::getMaxRSSDiff ( ) const
inline

Definition at line 116 of file Relation.h.

116  {
117  return postMaxRSS - preMaxRSS;
118  }

References postMaxRSS, and preMaxRSS.

◆ getName()

std::string souffle::profile::Relation::getName ( ) const
inline

Definition at line 183 of file Relation.h.

183  {
184  return name;
185  }

References name.

◆ getNonRecTime()

std::chrono::microseconds souffle::profile::Relation::getNonRecTime ( ) const
inline

Definition at line 88 of file Relation.h.

88  {
89  return endtime - starttime;
90  }

References endtime, and starttime.

Referenced by toString().

◆ getReads()

size_t souffle::profile::Relation::getReads ( ) const
inline

Definition at line 244 of file Relation.h.

244  {
245  return tuplesRead;
246  }

References tuplesRead.

◆ getRecTime()

std::chrono::microseconds souffle::profile::Relation::getRecTime ( ) const
inline

Definition at line 92 of file Relation.h.

92  {
93  std::chrono::microseconds result{};
94  for (auto& iter : iterations) {
95  result += iter->getRuntime();
96  }
97  return result;
98  }

References iterations.

◆ getRuleMap()

const std::unordered_map<std::string, std::shared_ptr<Rule> >& souffle::profile::Relation::getRuleMap ( ) const
inline

Return a map of Rules, indexed by srcLocator.

Returns
the ruleMap

Definition at line 192 of file Relation.h.

192  {
193  return ruleMap;
194  }

References ruleMap.

◆ getRuleRecList()

std::vector<std::shared_ptr<Rule> > souffle::profile::Relation::getRuleRecList ( ) const
inline

Definition at line 200 of file Relation.h.

200  {
201  std::vector<std::shared_ptr<Rule>> temp = std::vector<std::shared_ptr<Rule>>();
202  for (auto& iter : iterations) {
203  for (auto& rul : iter->getRules()) {
204  temp.push_back(rul.second);
205  }
206  }
207  return temp;
208  }

References iterations, and rul().

Here is the call graph for this function:

◆ getSavetime()

std::chrono::microseconds souffle::profile::Relation::getSavetime ( ) const
inline

Definition at line 76 of file Relation.h.

76  {
77  return savetime;
78  }

References savetime.

◆ getStarttime()

std::chrono::microseconds souffle::profile::Relation::getStarttime ( ) const
inline

Definition at line 80 of file Relation.h.

80  {
81  return starttime;
82  }

References starttime.

◆ getTotalRecursiveRuleSize()

size_t souffle::profile::Relation::getTotalRecursiveRuleSize ( ) const
inline

Definition at line 120 of file Relation.h.

120  {
121  size_t result = 0;
122  for (auto& iter : iterations) {
123  for (auto& rul : iter->getRules()) {
124  result += rul.second->size();
125  }
126  }
127  return result;
128  }

References iterations, and rul().

Here is the call graph for this function:

◆ isReady()

bool souffle::profile::Relation::isReady ( )
inline

Definition at line 236 of file Relation.h.

236  {
237  return ready;
238  }

References ready.

◆ setEndtime()

void souffle::profile::Relation::setEndtime ( std::chrono::microseconds  time)
inline

Definition at line 142 of file Relation.h.

142  {
143  endtime = time;
144  }

References endtime, and souffle::test::time().

Here is the call graph for this function:

◆ setLoadtime()

void souffle::profile::Relation::setLoadtime ( std::chrono::microseconds  loadtime)
inline

Definition at line 130 of file Relation.h.

130  {
131  this->loadtime = loadtime;
132  }

References loadtime.

◆ setLocator()

void souffle::profile::Relation::setLocator ( std::string  locator)
inline

Definition at line 232 of file Relation.h.

232  {
233  this->locator = locator;
234  }

References locator.

◆ setNumTuples()

void souffle::profile::Relation::setNumTuples ( long  numTuples)
inline

Definition at line 146 of file Relation.h.

146  {
147  nonRecTuples = numTuples;
148  }

References nonRecTuples.

◆ setPostMaxRSS()

void souffle::profile::Relation::setPostMaxRSS ( size_t  maxRSS)
inline

Definition at line 150 of file Relation.h.

150  {
151  postMaxRSS = std::max(maxRSS, postMaxRSS);
152  }

References postMaxRSS.

◆ setPreMaxRSS()

void souffle::profile::Relation::setPreMaxRSS ( size_t  maxRSS)
inline

Definition at line 154 of file Relation.h.

154  {
155  if (preMaxRSS == 0) {
156  preMaxRSS = maxRSS;
157  return;
158  }
159  preMaxRSS = std::min(maxRSS, preMaxRSS);
160  }

References preMaxRSS.

◆ setReady()

void souffle::profile::Relation::setReady ( bool  ready)
inline

Definition at line 240 of file Relation.h.

240  {
241  this->ready = ready;
242  }

References ready.

◆ setSavetime()

void souffle::profile::Relation::setSavetime ( std::chrono::microseconds  savetime)
inline

Definition at line 134 of file Relation.h.

134  {
135  this->savetime = savetime;
136  }

References savetime.

◆ setStarttime()

void souffle::profile::Relation::setStarttime ( std::chrono::microseconds  time)
inline

Definition at line 138 of file Relation.h.

138  {
139  starttime = time;
140  }

References starttime, and souffle::test::time().

Here is the call graph for this function:

◆ size()

size_t souffle::profile::Relation::size ( ) const
inline

Definition at line 108 of file Relation.h.

108  {
109  size_t result = 0;
110  for (auto& iter : iterations) {
111  result += iter->size();
112  }
113  return nonRecTuples + result;
114  }

References iterations, and nonRecTuples.

◆ toString()

std::string souffle::profile::Relation::toString ( ) const
inline

Definition at line 162 of file Relation.h.

162  {
163  std::ostringstream output;
164  output << "{\n\"" << name << "\":[" << getNonRecTime().count() << "," << nonRecTuples
165  << "],\n\n\"onRecRules\":[\n";
166  for (auto& rul : ruleMap) {
167  output << rul.second->toString();
168  }
169  output << "\n],\n\"iterations\":\n";
170  output << "[";
171  if (iterations.empty()) {
172  output << ", ";
173  }
174  for (auto& iter : iterations) {
175  output << iter->toString();
176  output << ", ";
177  }
178  std::string retStr = output.str();
179  // substring to remove the last comma
180  return retStr.substr(0, retStr.size() - 2) + "]\n}";
181  }

References getNonRecTime(), iterations, name, nonRecTuples, rul(), and ruleMap.

Here is the call graph for this function:

Field Documentation

◆ endtime

std::chrono::microseconds souffle::profile::Relation::endtime {}
private

Definition at line 33 of file Relation.h.

Referenced by addIteration(), getEndtime(), getNonRecTime(), and setEndtime().

◆ id

const std::string souffle::profile::Relation::id
private

Definition at line 39 of file Relation.h.

Referenced by getId().

◆ iterations

std::vector<std::shared_ptr<Iteration> > souffle::profile::Relation::iterations
private

◆ loadtime

std::chrono::microseconds souffle::profile::Relation::loadtime {}
private

Definition at line 34 of file Relation.h.

Referenced by getLoadtime(), and setLoadtime().

◆ locator

std::string souffle::profile::Relation::locator
private

Definition at line 40 of file Relation.h.

Referenced by getLocator(), and setLocator().

◆ name

const std::string souffle::profile::Relation::name
private

Definition at line 31 of file Relation.h.

Referenced by createRecID(), getName(), and toString().

◆ nonRecTuples

long souffle::profile::Relation::nonRecTuples = 0
private

Definition at line 36 of file Relation.h.

Referenced by setNumTuples(), size(), and toString().

◆ postMaxRSS

size_t souffle::profile::Relation::postMaxRSS = 0
private

Definition at line 38 of file Relation.h.

Referenced by getMaxRSSDiff(), and setPostMaxRSS().

◆ preMaxRSS

size_t souffle::profile::Relation::preMaxRSS = 0
private

Definition at line 37 of file Relation.h.

Referenced by getMaxRSSDiff(), and setPreMaxRSS().

◆ ready

bool souffle::profile::Relation::ready = true
private

Definition at line 49 of file Relation.h.

Referenced by isReady(), and setReady().

◆ recursiveId

int souffle::profile::Relation::recursiveId = 0
private

Definition at line 42 of file Relation.h.

Referenced by createRecID().

◆ ruleId

int souffle::profile::Relation::ruleId = 0
private

Definition at line 41 of file Relation.h.

Referenced by createID().

◆ ruleMap

std::unordered_map<std::string, std::shared_ptr<Rule> > souffle::profile::Relation::ruleMap
private

Definition at line 47 of file Relation.h.

Referenced by addRule(), getRuleMap(), Relation(), and toString().

◆ savetime

std::chrono::microseconds souffle::profile::Relation::savetime {}
private

Definition at line 35 of file Relation.h.

Referenced by getSavetime(), and setSavetime().

◆ starttime

std::chrono::microseconds souffle::profile::Relation::starttime {}
private

Definition at line 32 of file Relation.h.

Referenced by addIteration(), getNonRecTime(), getStarttime(), and setStarttime().

◆ tuplesRead

size_t souffle::profile::Relation::tuplesRead = 0
private

Definition at line 43 of file Relation.h.

Referenced by addReads(), and getReads().


The documentation for this class was generated from the following file:
souffle::profile::Relation::tuplesRead
size_t tuplesRead
Definition: Relation.h:43
souffle::profile::Relation::savetime
std::chrono::microseconds savetime
Definition: Relation.h:35
souffle::profile::Relation::ready
bool ready
Definition: Relation.h:49
iteration
Iteration & iteration
Definition: Reader.h:129
souffle::profile::Relation::name
const std::string name
Definition: Relation.h:31
souffle::profile::Relation::preMaxRSS
size_t preMaxRSS
Definition: Relation.h:37
souffle::profile::Relation::getNonRecTime
std::chrono::microseconds getNonRecTime() const
Definition: Relation.h:88
souffle::profile::Relation::locator
std::string locator
Definition: Relation.h:40
souffle::profile::Relation::starttime
std::chrono::microseconds starttime
Definition: Relation.h:32
souffle::profile::Relation::nonRecTuples
long nonRecTuples
Definition: Relation.h:36
rul
void rul(size_t limit, bool showLimit=true)
Definition: Tui.h:1106
souffle::profile::Relation::postMaxRSS
size_t postMaxRSS
Definition: Relation.h:38
souffle::profile::Relation::iterations
std::vector< std::shared_ptr< Iteration > > iterations
Definition: Relation.h:45
souffle::profile::Relation::recursiveId
int recursiveId
Definition: Relation.h:42
souffle::profile::Relation::id
const std::string id
Definition: Relation.h:39
souffle::test::time
long time(const std::string &name, const Op &operation)
Definition: btree_multiset_test.cpp:411
souffle::ast::DirectiveType::output
@ output
rule
Rule & rule
Definition: Reader.h:85
souffle::profile::Relation::ruleId
int ruleId
Definition: Relation.h:41
souffle::profile::Relation::getEndtime
std::chrono::microseconds getEndtime() const
Definition: Relation.h:84
souffle::profile::Relation::loadtime
std::chrono::microseconds loadtime
Definition: Relation.h:34
souffle::profile::Relation::endtime
std::chrono::microseconds endtime
Definition: Relation.h:33
souffle::profile::Relation::ruleMap
std::unordered_map< std::string, std::shared_ptr< Rule > > ruleMap
Definition: Relation.h:47