From 6cdee6531b7ea9fece50dd43aa2007e5abd9ab02 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Wed, 19 Mar 2025 13:19:38 -0700 Subject: [PATCH] new time limit API --- ortools/util/time_limit.cc | 2 ++ ortools/util/time_limit.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/ortools/util/time_limit.cc b/ortools/util/time_limit.cc index d856e404b6..8950100531 100644 --- a/ortools/util/time_limit.cc +++ b/ortools/util/time_limit.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/flags/flag.h" +#include "absl/log/die_if_null.h" #include "absl/strings/str_cat.h" ABSL_FLAG(bool, time_limit_use_usertime, false, diff --git a/ortools/util/time_limit.h b/ortools/util/time_limit.h index 0ad1d8589d..eccb686d26 100644 --- a/ortools/util/time_limit.h +++ b/ortools/util/time_limit.h @@ -27,6 +27,7 @@ #include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" #include "absl/time/time.h" @@ -511,6 +512,10 @@ inline bool TimeLimit::LimitReached() { const int64_t current_ns = absl::GetCurrentTimeNanos(); running_max_.Add(std::max(safety_buffer_ns_, current_ns - last_ns_)); + VLOG_EVERY_N_SEC(2, 2) << "current_ns: " << current_ns + << " last_ns: " << last_ns_ + << " limit_ns: " << limit_ns_ + << " running_max: " << running_max_.GetCurrentMax(); last_ns_ = current_ns; if (current_ns + running_max_.GetCurrentMax() >= limit_ns_) { if (absl::GetFlag(FLAGS_time_limit_use_usertime)) {