Skip to content

Commit

Permalink
Merge pull request #713 from mmcgr/ProfileDB
Browse files Browse the repository at this point in the history
Add relation and rule count to profile logs and profiler top command
  • Loading branch information
Bernhard Scholz authored Sep 4, 2018
2 parents 2d1d11e + 3b4fc82 commit 76881a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,11 @@ void Interpreter::executeMain() {
});
ProfileEventSingleton::instance().makeConfigRecord("relationCount", std::to_string(relationCount));

// Store count of rules
size_t ruleCount = 0;
visitDepthFirst(main, [&](const RamInsert& rule) { ++ruleCount; });
ProfileEventSingleton::instance().makeConfigRecord("ruleCount", std::to_string(ruleCount));

evalStmt(main);
ProfileEventSingleton::instance().stopTimer();
for (auto const& cur : frequencies) {
Expand Down
30 changes: 23 additions & 7 deletions src/profile/Tui.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,22 +732,38 @@ class Tui {
void top() {
std::shared_ptr<ProgramRun>& run = out.getProgramRun();
if (alive) run->update();
std::printf("%11s%10s%10s%20s\n", "runtime", "loadtime", "savetime", "tuples generated");
auto* totalRelationsEntry =
dynamic_cast<TextEntry*>(ProfileEventSingleton::instance().getDB().lookupEntry(
{"program", "configuration", "relationCount"}));
auto* totalRulesEntry =
dynamic_cast<TextEntry*>(ProfileEventSingleton::instance().getDB().lookupEntry(
{"program", "configuration", "ruleCount"}));
size_t totalRelations = 0;
if (totalRelationsEntry != nullptr) {
totalRelations = std::stoul(totalRelationsEntry->getText());
} else {
totalRelations = run->getRelation_map().size();
}
size_t totalRules = 0;
if (totalRulesEntry != nullptr) {
totalRules = std::stoul(totalRulesEntry->getText());
} else {
totalRules = rul_table_state.getRows().size();
}
std::printf("%11s%10s%10s%10s%10s%20s\n", "runtime", "loadtime", "savetime", "relations", "rules",
"tuples generated");

std::printf("%11s%10s%10s%14s\n", run->getRuntime().c_str(),
std::printf("%11s%10s%10s%10s%10s%14s\n", run->getRuntime().c_str(),
run->formatTime(run->getTotLoadtime()).c_str(),
run->formatTime(run->getTotSavetime()).c_str(),
run->formatTime(run->getTotSavetime()).c_str(), run->formatNum(0, totalRelations).c_str(),
run->formatNum(0, totalRules).c_str(),
run->formatNum(precision, run->getTotNumTuples()).c_str());

// Progress bar
auto* totalRelationsEntry =
dynamic_cast<TextEntry*>(ProfileEventSingleton::instance().getDB().lookupEntry(
{"program", "configuration", "relationCount"}));
// Determine number of relations processed
size_t processedRelations = run->getRelation_map().size();
size_t screenWidth = getTermWidth() - 10;
if (alive && totalRelationsEntry != nullptr) {
size_t totalRelations = std::stoul(totalRelationsEntry->getText());
std::cout << "Progress ";
for (size_t i = 0; i < screenWidth; ++i) {
if (screenWidth * processedRelations / totalRelations > i) {
Expand Down

0 comments on commit 76881a0

Please sign in to comment.