This makes the `driver::totalTime` statistic a `TimerStat`. This eliminates the need to obtain the overall runtime in the driver and write it to the statistics towards the end of the runtime. This not only eliminates some code in the driver, but also gets rid of the call to `getSmtEngine()` that goes around the API.
One disclaimer: The statistics output changes from seconds as a double (i.e. `1.234`) to milliseconds (i.e. `1234ms`).
#include <stdio.h>
#include <unistd.h>
-#include <chrono>
#include <cstdlib>
#include <cstring>
#include <fstream>
/** A pointer to the CommandExecutor (the signal handlers need it) */
std::unique_ptr<cvc5::main::CommandExecutor> pExecutor;
-/** The time point the binary started, accessible to signal handlers */
-std::unique_ptr<TotalTimer> totalTime;
-
-TotalTimer::~TotalTimer()
-{
- if (pExecutor != nullptr)
- {
- auto duration = std::chrono::steady_clock::now() - d_start;
- pExecutor->getSmtEngine()->setTotalTimeStatistic(
- std::chrono::duration<double>(duration).count());
- }
- }
-
- } // namespace main
- } // namespace cvc5
+} // namespace main
+} // namespace cvc5
void printUsage(const api::DriverOptions& dopts, bool full)
{
int runCvc5(int argc, char* argv[], std::unique_ptr<api::Solver>& solver)
{
- main::totalTime = std::make_unique<TotalTimer>();
-
// Initialize the signal handlers
signal_handlers::install();
int returnValue = 0;
{
- // notify SmtEngine that we are starting to parse
- pExecutor->getSmtEngine()->setInfo("filename", filenameStr);
+ // pass filename to solver (options & statistics)
+ solver->setInfo("filename", filenameStr);
// Parse and execute commands until we are done
std::unique_ptr<Command> cmd;
_exit(returnValue);
#endif /* CVC5_COMPETITION_MODE */
- totalTime.reset();
pExecutor->flushOutputStreams();
#ifdef CVC5_DEBUG
if (solver->getOptionInfo("stats").boolValue()
&& main::pExecutor != nullptr)
{
- totalTime.reset();
pExecutor->printStatistics(solver->getDriverOptions().err());
}
}
* Header for main cvc5 driver.
*/
-#include <chrono>
-#include <exception>
#include <memory>
#include <string>
#include "api/cpp/cvc5.h"
#include "base/cvc5config.h"
-#include "base/exception.h"
-#include "options/options.h"
#ifndef CVC5__MAIN__MAIN_H
#define CVC5__MAIN__MAIN_H
/** A reference for use by the signal handlers to print statistics */
extern std::unique_ptr<cvc5::main::CommandExecutor> pExecutor;
-/** Manages a custom timer for the total runtime in RAII-style. */
-class TotalTimer
-{
- public:
- TotalTimer() : d_start(std::chrono::steady_clock::now()) {}
- ~TotalTimer();
-
- private:
- std::chrono::steady_clock::time_point d_start;
-};
-/** The time point the binary started, accessible to signal handlers */
-extern std::unique_ptr<TotalTimer> totalTime;
-
/**
* If true, will not spin on segfault even when CVC5_DEBUG is on.
* Useful for nightly regressions, noninteractive performance runs
{
if (pExecutor != nullptr)
{
- totalTime.reset();
pExecutor->printStatisticsSafe(STDERR_FILENO);
}
}
{
d_options.copyValues(*opts);
}
+ d_statisticsRegistry->registerTimer("global::totalTime").start();
d_resourceManager = std::make_unique<ResourceManager>(*d_statisticsRegistry, d_options);
}
return res;
}
-void SmtEngine::setTotalTimeStatistic(double seconds) {
- d_env->getStatisticsRegistry().registerValue<double>("driver::totalTime",
- seconds);
-}
-
void SmtEngine::setLogicInternal()
{
Assert(!d_state->isFullyInited())
/** Is this an internal subsolver? */
bool isInternalSubsolver() const;
- /**
- * Helper method for the API to put the total runtime into the statistics.
- */
- void setTotalTimeStatistic(double seconds) CVC5_EXPORT;
-
/**
* Get the model (only if immediately preceded by a SAT or NOT_ENTAILED
* query). Only permitted if produce-models is on.
reg.registerHistogram<api::Kind>("api::TERM", false);
reg.registerValue<std::string>("driver::filename", false);
- reg.registerValue<double>("driver::totalTime", false);
+ reg.registerTimer("global::totalTime", false);
for (theory::TheoryId id = theory::THEORY_FIRST; id != theory::THEORY_LAST;
++id)