 |
OR-Tools
8.0
|
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_;
180 void Reset()
override;
248 const double cycles =
static_cast<double>(timer_.
GetCycles());
256 static std::string PrintCyclesAsTime(
double cycles);
311 : stat_(stat), also_update_(nullptr) {
316 if (also_update_ !=
nullptr) {
347 #ifdef HAS_PERF_SUBSYSTEM
355 class EnabledScopedInstructionCounter {
357 explicit EnabledScopedInstructionCounter(
const std::string&
name,
359 EnabledScopedInstructionCounter(
const EnabledScopedInstructionCounter&) =
361 EnabledScopedInstructionCounter& operator=(
362 const EnabledScopedInstructionCounter&) =
delete;
363 ~EnabledScopedInstructionCounter();
366 double ReadInstructionCount() {
return ending_count_ - starting_count_; }
369 TimeLimit* time_limit_;
371 double starting_count_;
372 double ending_count_;
374 #endif // HAS_PERF_SUBSYSTEM
388 #ifdef HAS_PERF_SUBSYSTEM
390 #else // HAS_PERF_SUBSYSTEM
392 #endif // HAS_PERF_SUBSYSTEM
396 #define IF_STATS_ENABLED(instructions) instructions
405 #define SCOPED_TIME_STAT(stats) \
406 operations_research::ScopedTimeDistributionUpdater scoped_time_stat( \
407 (stats)->LookupOrCreateTimeDistribution(__FUNCTION__))
409 #ifdef HAS_PERF_SUBSYSTEM
411 inline std::string RemoveOperationsResearchAndGlop(
412 const std::string& pretty_function) {
413 return strings::GlobalReplaceSubstrings(
414 pretty_function, {{
"operations_research::",
""}, {
"glop::",
""}});
417 #define SCOPED_INSTRUCTION_COUNT(time_limit) \
418 operations_research::ScopedInstructionCounter scoped_instruction_count( \
419 RemoveOperationsResearchAndGlop(__PRETTY_FUNCTION__), time_limit)
421 #endif // HAS_PERF_SUBSYSTEM
430 #define IF_STATS_ENABLED(instructions)
431 #define SCOPED_TIME_STAT(stats)
432 #define SCOPED_INSTRUCTION_COUNT(time_limit)
438 #endif // OR_TOOLS_UTIL_STATS_H_
std::string ValueAsString() const override
std::string StatString() const
TimeDistribution(const std::string &name)
std::string ValueAsString() const override
void AlsoUpdate(TimeDistribution *also_update)
RatioDistribution(const std::string &name)
double StopTimerAndAddElapsedTime()
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
DisabledScopedTimeDistributionUpdater(TimeDistribution *stat)
@ SORT_BY_PRIORITY_THEN_VALUE
std::string MemoryUsage()
void AddToDistribution(double value)
static double CyclesToSeconds(double num_cycles)
IntegerDistribution(const std::string &name, StatsGroup *group)
int Priority() const override
~EnabledScopedTimeDistributionUpdater()
virtual int Priority() const
DisabledScopedInstructionCounter & operator=(const DisabledScopedInstructionCounter &)=delete
virtual std::string ValueAsString() const =0
bool WorthPrinting() const override
SharedTimeLimit * time_limit
DoubleDistribution(const std::string &name)
DistributionStat(const std::string &name)
IntegerDistribution(const std::string &name)
RatioDistribution(const std::string &name, StatsGroup *group)
std::string ValueAsString() const override=0
Stat(const std::string &name)
TimeDistribution * LookupOrCreateTimeDistribution(std::string name)
void AlsoUpdate(TimeDistribution *also_update)
void AddTimeInSec(double seconds)
StatsGroup(const std::string &name)
void Register(Stat *stat)
virtual double Sum() const
void SetPrintOrder(PrintOrder print_order)
double sum_squares_from_average_
double Sum() const override
EnabledScopedTimeDistributionUpdater(TimeDistribution *stat)
DisabledScopedInstructionCounter(const DisabledScopedInstructionCounter &)=delete
std::string ValueAsString() const override
std::string StatString() const
DisabledScopedInstructionCounter(const std::string &name)
TimeDistribution(const std::string &name, StatsGroup *group)
~DistributionStat() override
double StdDeviation() const
void AddTimeInCycles(double cycles)
std::string ValueAsString() const override
DoubleDistribution(const std::string &name, StatsGroup *group)
virtual bool WorthPrinting() const =0