16 #include "absl/strings/str_cat.h" 18 ABSL_FLAG(
bool, time_limit_use_usertime,
false,
19 "If true, rely on the user time in the TimeLimit class. This is " 20 "only recommended for benchmarking on a non-isolated environment.");
22 ABSL_FLAG(
bool, time_limit_use_instruction_count,
false,
23 "If true, measures the number of instructions executed");
32 std::string buffer = absl::StrCat(
38 for (
const auto& counter : deterministic_counters_) {
39 const std::string& counter_name = counter.first;
40 const double counter_value = counter.second;
41 absl::StrAppend(&buffer,
"\n", counter_name,
": ", (counter_value));
48 double limit_in_seconds,
49 double deterministic_limit)
51 time_limit_(std::
min(base_time_limit_->GetTimeLeft(), limit_in_seconds),
52 std::
min(base_time_limit_->GetDeterministicTimeLeft(),
53 deterministic_limit)) {
54 if (base_time_limit_->external_boolean_as_limit_ !=
nullptr) {
56 base_time_limit_->external_boolean_as_limit_);
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
double GetDeterministicTimeLeft() const
Returns the remaining deterministic time before LimitReached() returns true due to the deterministic ...
NestedTimeLimit(TimeLimit *base_time_limit, double limit_in_seconds, double deterministic_limit)
Creates the nested time limit.
std::string DebugString() const
Returns information about the time limit object in a human-readable form.
~NestedTimeLimit()
Updates elapsed deterministic time in the base time limit object.
double GetElapsedDeterministicTime() const
Returns the elapsed deterministic time since the construction of this object.
double GetElapsedTime() const
Returns the time elapsed in seconds since the construction of this object.
double GetTimeLeft() const
Returns the time left on this limit, or 0 if the limit was reached (it never returns a negative value...
void AdvanceDeterministicTime(double deterministic_duration)
Advances the deterministic time.
ABSL_FLAG(bool, time_limit_use_usertime, false, "If true, rely on the user time in the TimeLimit class. This is " "only recommended for benchmarking on a non-isolated environment.")
void RegisterExternalBooleanAsLimit(std::atomic< bool > *external_boolean_as_limit)
Registers the external Boolean to check when LimitReached() is called.
Collection of objects used to extend the Constraint Solver library.
static const int kHistorySize
static const double kSafetyBufferSeconds