souffle  2.0.2-371-g6315b36
Iteration.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2016, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 #pragma once
10 
11 #include "souffle/profile/Rule.h"
12 #include <chrono>
13 #include <cstddef>
14 #include <memory>
15 #include <sstream>
16 #include <string>
17 #include <unordered_map>
18 #include <utility>
19 
20 namespace souffle {
21 namespace profile {
22 
23 /*
24  * Represents recursive profile data
25  */
26 class Iteration {
27 private:
28  std::chrono::microseconds starttime{};
29  std::chrono::microseconds endtime{};
30  size_t numTuples = 0;
31  std::chrono::microseconds copytime{};
32  std::string locator = "";
33 
34  std::unordered_map<std::string, std::shared_ptr<Rule>> rules;
35 
36 public:
37  Iteration() : rules() {}
38 
39  void addRule(const std::string& ruleKey, std::shared_ptr<Rule>& rule) {
40  rules[ruleKey] = rule;
41  }
42 
43  const std::unordered_map<std::string, std::shared_ptr<Rule>>& getRules() const {
44  return rules;
45  }
46 
47  std::string toString() const {
48  std::ostringstream output;
49 
50  output << getRuntime().count() << "," << numTuples << "," << copytime.count() << ",";
51  output << " recRule:";
52  for (auto& rul : rules) {
53  output << rul.second->toString();
54  }
55  output << "\n";
56  return output.str();
57  }
58 
59  std::chrono::microseconds getRuntime() const {
60  return endtime - starttime;
61  }
62 
63  std::chrono::microseconds getStarttime() const {
64  return starttime;
65  }
66 
67  std::chrono::microseconds getEndtime() const {
68  return endtime;
69  }
70 
71  size_t size() const {
72  return numTuples;
73  }
74 
75  void setNumTuples(long numTuples) {
76  this->numTuples = numTuples;
77  }
78 
79  std::chrono::microseconds getCopytime() const {
80  return copytime;
81  }
82 
83  void setCopytime(std::chrono::microseconds copy_time) {
84  this->copytime = copy_time;
85  }
86 
87  void setStarttime(std::chrono::microseconds time) {
88  starttime = time;
89  }
90 
91  void setEndtime(std::chrono::microseconds time) {
92  endtime = time;
93  }
94 
95  const std::string& getLocator() const {
96  return locator;
97  }
98 
99  void setLocator(std::string locator) {
100  this->locator = locator;
101  }
102 };
103 
104 } // namespace profile
105 } // namespace souffle
souffle::profile::Iteration
Definition: Iteration.h:26
souffle::profile::Iteration::getRules
const std::unordered_map< std::string, std::shared_ptr< Rule > > & getRules() const
Definition: Iteration.h:43
souffle::profile::Iteration::getLocator
const std::string & getLocator() const
Definition: Iteration.h:95
souffle::profile::Iteration::numTuples
size_t numTuples
Definition: Iteration.h:30
souffle::profile::Iteration::setNumTuples
void setNumTuples(long numTuples)
Definition: Iteration.h:75
souffle::profile::Iteration::rules
std::unordered_map< std::string, std::shared_ptr< Rule > > rules
Definition: Iteration.h:34
souffle::profile::Iteration::locator
std::string locator
Definition: Iteration.h:32
souffle::profile::Iteration::endtime
std::chrono::microseconds endtime
Definition: Iteration.h:29
souffle::profile::Iteration::setLocator
void setLocator(std::string locator)
Definition: Iteration.h:99
souffle::profile::Iteration::copytime
std::chrono::microseconds copytime
Definition: Iteration.h:31
souffle::profile::Iteration::toString
std::string toString() const
Definition: Iteration.h:47
souffle::profile::Iteration::starttime
std::chrono::microseconds starttime
Definition: Iteration.h:28
souffle::profile::Iteration::size
size_t size() const
Definition: Iteration.h:71
souffle::profile::Iteration::setCopytime
void setCopytime(std::chrono::microseconds copy_time)
Definition: Iteration.h:83
souffle::profile::Iteration::getStarttime
std::chrono::microseconds getStarttime() const
Definition: Iteration.h:63
rul
void rul(size_t limit, bool showLimit=true)
Definition: Tui.h:1106
souffle::profile::Iteration::getRuntime
std::chrono::microseconds getRuntime() const
Definition: Iteration.h:59
souffle::profile::Iteration::setStarttime
void setStarttime(std::chrono::microseconds time)
Definition: Iteration.h:87
souffle::profile::Iteration::Iteration
Iteration()
Definition: Iteration.h:37
souffle::test::time
long time(const std::string &name, const Op &operation)
Definition: btree_multiset_test.cpp:411
souffle::profile::Iteration::addRule
void addRule(const std::string &ruleKey, std::shared_ptr< Rule > &rule)
Definition: Iteration.h:39
Rule.h
rule
Rule & rule
Definition: Reader.h:85
souffle
Definition: AggregateOp.h:25
souffle::profile::Iteration::getEndtime
std::chrono::microseconds getEndtime() const
Definition: Iteration.h:67
souffle::profile::Iteration::setEndtime
void setEndtime(std::chrono::microseconds time)
Definition: Iteration.h:91
souffle::profile::Iteration::getCopytime
std::chrono::microseconds getCopytime() const
Definition: Iteration.h:79