diff options
author | Gereon Kremer <gereon.kremer@cs.rwth-aachen.de> | 2021-04-02 19:47:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 17:47:43 +0000 |
commit | 2506e17ca86c42b7590f65326b70a69b0efdb0bd (patch) | |
tree | cf1686ebfa22300f03f60b0e80a9a8fdb6ddd33c /src/main/command_executor.cpp | |
parent | da3eff9ba6c632e290c9af990dc5750f65d78820 (diff) |
Minor refactoring (#6273)
This PR does some minor refactorings in preparation for the new statistics: some renamings, removal of now obsolete code and usage of references instead of pointers.
Diffstat (limited to 'src/main/command_executor.cpp')
-rw-r--r-- | src/main/command_executor.cpp | 68 |
1 files changed, 13 insertions, 55 deletions
diff --git a/src/main/command_executor.cpp b/src/main/command_executor.cpp index 6152064be..b7e3ad8b0 100644 --- a/src/main/command_executor.cpp +++ b/src/main/command_executor.cpp @@ -61,16 +61,20 @@ CommandExecutor::~CommandExecutor() d_solver.reset(nullptr); } -void CommandExecutor::flushStatistics(std::ostream& out) const +void CommandExecutor::printStatistics(std::ostream& out) const { - // SmtEngine + node manager flush statistics is part of the call below - getSmtEngine()->flushStatistics(out); + if (d_options.getStatistics()) + { + getSmtEngine()->printStatistics(out); + } } -void CommandExecutor::safeFlushStatistics(int fd) const +void CommandExecutor::printStatisticsSafe(int fd) const { - // SmtEngine + node manager flush statistics is part of the call below - getSmtEngine()->safeFlushStatistics(fd); + if (d_options.getStatistics()) + { + getSmtEngine()->printStatisticsSafe(fd); + } } bool CommandExecutor::doCommand(Command* cmd) @@ -103,10 +107,7 @@ bool CommandExecutor::doCommand(Command* cmd) void CommandExecutor::reset() { - if (d_options.getStatistics()) - { - flushStatistics(*d_options.getErr()); - } + printStatistics(*d_options.getErr()); /* We have to keep options passed via CL on reset. These options are stored * in CommandExecutor::d_options (populated and created in the driver), and * CommandExecutor::d_options only contains *these* options since the @@ -144,7 +145,7 @@ bool CommandExecutor::doCommandSingleton(Command* cmd) if((cs != nullptr || q != nullptr) && d_options.getStatsEveryQuery()) { std::ostringstream ossCurStats; - flushStatistics(ossCurStats); + printStatistics(ossCurStats); std::ostream& err = *d_options.getErr(); printStatsIncremental(err, d_lastStatistics, ossCurStats.str()); d_lastStatistics = ossCurStats.str(); @@ -280,51 +281,8 @@ void printStatsIncremental(std::ostream& out, } } -void CommandExecutor::printStatsFilterZeros(std::ostream& out, - const std::string& statsString) { - // read each line, if a number, check zero and skip if so - // Stat are assumed to one-per line: "<statName>, <statValue>" - - std::istringstream iss(statsString); - std::string statName, statValue; - - std::getline(iss, statName, ','); - - while (!iss.eof()) - { - std::getline(iss, statValue, '\n'); - - bool skip = false; - try - { - double dval = std::stod(statValue); - skip = (dval == 0.0); - } - // Value can not be converted, don't skip - catch (const std::invalid_argument&) {} - catch (const std::out_of_range&) {} - - skip = skip || (statValue == " \"0\"" || statValue == " \"[]\""); - - if (!skip) - { - out << statName << "," << statValue << std::endl; - } - - std::getline(iss, statName, ','); - } -} - void CommandExecutor::flushOutputStreams() { - if(d_options.getStatistics()) { - if(d_options.getStatsHideZeros() == false) { - flushStatistics(*(d_options.getErr())); - } else { - std::ostringstream ossStats; - flushStatistics(ossStats); - printStatsFilterZeros(*(d_options.getErr()), ossStats.str()); - } - } + printStatistics(*(d_options.getErr())); // make sure out and err streams are flushed too d_options.flushOut(); |