 |
OR-Tools
8.1
|
Go to the documentation of this file.
68 #ifndef OR_TOOLS_UTIL_STATS_H_
69 #define OR_TOOLS_UTIL_STATS_H_
74 #ifdef HAS_PERF_SUBSYSTEM
75 #include "absl/strings/str_replace.h"
76 #include "exegesis/exegesis/itineraries/perf_subsystem.h"
78 #endif // HAS_PERF_SUBSYSTEM
90 class TimeDistribution;
102 std::string
Name()
const {
return name_; }
115 virtual double Sum()
const {
return 0; }
127 const std::string name_;
139 : name_(
name), stats_(), time_distributions_() {}
166 std::vector<Stat*> stats_;
167 std::map<std::string, TimeDistribution*> time_distributions_;
181 void Reset()
override;
250 const double cycles =
static_cast<double>(timer_.
GetCycles());
258 static std::string PrintCyclesAsTime(
double cycles);
316 : stat_(stat), also_update_(nullptr) {
321 if (also_update_ !=
nullptr) {
352 #ifdef HAS_PERF_SUBSYSTEM
360 class EnabledScopedInstructionCounter {
362 explicit EnabledScopedInstructionCounter(
const std::string&
name,
364 EnabledScopedInstructionCounter(
const EnabledScopedInstructionCounter&) =
366 EnabledScopedInstructionCounter& operator=(
367 const EnabledScopedInstructionCounter&) =
delete;
368 ~EnabledScopedInstructionCounter();
371 double ReadInstructionCount() {
return ending_count_ - starting_count_; }
374 TimeLimit* time_limit_;
376 double starting_count_;
377 double ending_count_;
379 #endif // HAS_PERF_SUBSYSTEM
393 #ifdef HAS_PERF_SUBSYSTEM
395 #else // HAS_PERF_SUBSYSTEM
397 #endif // HAS_PERF_SUBSYSTEM
401 #define IF_STATS_ENABLED(instructions) instructions
410 #define SCOPED_TIME_STAT(stats) \
411 operations_research::ScopedTimeDistributionUpdater scoped_time_stat( \
412 (stats)->LookupOrCreateTimeDistribution(__FUNCTION__))
414 #ifdef HAS_PERF_SUBSYSTEM
416 inline std::string RemoveOperationsResearchAndGlop(
417 const std::string& pretty_function) {
418 return strings::GlobalReplaceSubstrings(
419 pretty_function, {{
"operations_research::",
""}, {
"glop::",
""}});
422 #define SCOPED_INSTRUCTION_COUNT(time_limit) \
423 operations_research::ScopedInstructionCounter scoped_instruction_count( \
424 RemoveOperationsResearchAndGlop(__PRETTY_FUNCTION__), time_limit)
426 #endif // HAS_PERF_SUBSYSTEM
435 #define IF_STATS_ENABLED(instructions)
436 #define SCOPED_TIME_STAT(stats)
437 #define SCOPED_INSTRUCTION_COUNT(time_limit)
443 #endif // OR_TOOLS_UTIL_STATS_H_
std::string ValueAsString() const override
StatsGroup(const std::string &name)
DoubleDistribution(const std::string &name, StatsGroup *group)
~DistributionStat() override
void AddToDistribution(double value)
virtual int Priority() const
DoubleDistribution(const std::string &name)
TimeDistribution(const std::string &name)
TimeDistribution * LookupOrCreateTimeDistribution(std::string name)
std::string ValueAsString() const override
virtual bool WorthPrinting() const =0
RatioDistribution(const std::string &name)
std::string ValueAsString() const override
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
DisabledScopedInstructionCounter & operator=(const DisabledScopedInstructionCounter &)=delete
Stat(const std::string &name)
std::string ValueAsString() const override
std::string MemoryUsage()
TimeDistribution(const std::string &name, StatsGroup *group)
virtual double Sum() const
std::string StatString() const
@ SORT_BY_PRIORITY_THEN_VALUE
double StdDeviation() const
std::string ValueAsString() const override=0
DisabledScopedTimeDistributionUpdater(TimeDistribution *stat)
void AddTimeInCycles(double cycles)
IntegerDistribution(const std::string &name, StatsGroup *group)
double StopTimerAndAddElapsedTime()
SharedTimeLimit * time_limit
void AddTimeInSec(double seconds)
int Priority() const override
static double CyclesToSeconds(double num_cycles)
void Register(Stat *stat)
DisabledScopedInstructionCounter(const DisabledScopedInstructionCounter &)=delete
DisabledScopedInstructionCounter(const std::string &name)
IntegerDistribution(const std::string &name)
RatioDistribution(const std::string &name, StatsGroup *group)
void AlsoUpdate(TimeDistribution *also_update)
void AlsoUpdate(TimeDistribution *also_update)
EnabledScopedTimeDistributionUpdater(TimeDistribution *stat)
void SetPrintOrder(PrintOrder print_order)
double Sum() const override
double sum_squares_from_average_
bool WorthPrinting() const override
std::string StatString() const
virtual std::string ValueAsString() const =0
~EnabledScopedTimeDistributionUpdater()