OILS / vendor / souffle / profile / Iteration.h View on Github | oilshell.org

105 lines, 56 significant
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
20namespace souffle {
21namespace profile {
22
23/*
24 * Represents recursive profile data
25 */
26class Iteration {
27private:
28 std::chrono::microseconds starttime{};
29 std::chrono::microseconds endtime{};
30 std::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
36public:
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 std::size_t size() const {
72 return numTuples;
73 }
74
75 void setNumTuples(std::size_t 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