Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::TimeDistribution Class Reference

#include <stats.h>

Inheritance diagram for operations_research::TimeDistribution:
operations_research::DistributionStat operations_research::Stat

Public Member Functions

 TimeDistribution (absl::string_view name)
 
 TimeDistribution ()
 
 TimeDistribution (absl::string_view name, StatsGroup *group)
 
std::string ValueAsString () const override
 Implemented by the subclasses.
 
int Priority () const override
 Time distributions have a high priority to be displayed first.
 
void AddTimeInSec (double seconds)
 Adds a time in seconds to this distribution.
 
void AddTime (absl::Duration duration)
 
void AddTimeInCycles (double cycles)
 Adds a time in CPU cycles to this distribution.
 
void StartTimer ()
 Starts the timer in preparation of a StopTimerAndAddElapsedTime().
 
double StopTimerAndAddElapsedTime ()
 
- Public Member Functions inherited from operations_research::DistributionStat
 DistributionStat (absl::string_view name)
 
 DistributionStat ()
 
 DistributionStat (absl::string_view name, StatsGroup *group)
 
 ~DistributionStat () override
 
void Reset () override
 Reset this statistic to the same state as if it was newly created.
 
bool WorthPrinting () const override
 Is this stat worth printing? Usually false if nothing was measured.
 
double Sum () const override
 Trivial statistics on all the values added so far.
 
double Max () const
 
double Min () const
 
int64_t Num () const
 
double Average () const
 Get the average of the distribution or 0.0 if empty.
 
double StdDeviation () const
 
- Public Member Functions inherited from operations_research::Stat
 Stat (absl::string_view name)
 
 Stat (absl::string_view name, StatsGroup *group)
 Also add this stat to the given group.
 
virtual ~Stat ()
 
std::string Name () const
 Only used for display purposes.
 
std::string StatString () const
 

Static Public Member Functions

static double CyclesToSeconds (double num_cycles)
 

Additional Inherited Members

- Protected Member Functions inherited from operations_research::DistributionStat
void AddToDistribution (double value)
 Adds a value to this sequence and updates the stats.
 
- Protected Attributes inherited from operations_research::DistributionStat
double sum_
 
double average_
 
double sum_squares_from_average_
 
double min_
 
double max_
 
int64_t num_
 

Detailed Description

Statistic on the distribution of a sequence of running times. Also provides some facility to measure such time with the CPU cycle counter.

Todo
(user): Since we inherit from DistributionStat, we currently store the sum of CPU cycles as a double internally. A better option is to use int64_t because with the 53 bits of precision of a double, we will run into an issue if the sum of times reaches 52 days for a 2GHz processor.

Definition at line 220 of file stats.h.

Constructor & Destructor Documentation

◆ TimeDistribution() [1/3]

operations_research::TimeDistribution::TimeDistribution ( absl::string_view name)
inlineexplicit

Definition at line 222 of file stats.h.

◆ TimeDistribution() [2/3]

operations_research::TimeDistribution::TimeDistribution ( )
inline

Definition at line 224 of file stats.h.

◆ TimeDistribution() [3/3]

operations_research::TimeDistribution::TimeDistribution ( absl::string_view name,
StatsGroup * group )
inline

Definition at line 225 of file stats.h.

Member Function Documentation

◆ AddTime()

void operations_research::TimeDistribution::AddTime ( absl::Duration duration)
inline

Definition at line 239 of file stats.h.

◆ AddTimeInCycles()

void operations_research::TimeDistribution::AddTimeInCycles ( double cycles)

Adds a time in CPU cycles to this distribution.

Definition at line 205 of file stats.cc.

◆ AddTimeInSec()

void operations_research::TimeDistribution::AddTimeInSec ( double seconds)

Adds a time in seconds to this distribution.

Definition at line 199 of file stats.cc.

◆ CyclesToSeconds()

double operations_research::TimeDistribution::CyclesToSeconds ( double num_cycles)
static

Internally the TimeDistribution stores CPU cycles (to do a bit less work on each StopTimerAndAddElapsedTime()). Use this function to convert all the statistics of DistributionStat into seconds.

Definition at line 181 of file stats.cc.

◆ Priority()

int operations_research::TimeDistribution::Priority ( ) const
inlineoverridevirtual

Time distributions have a high priority to be displayed first.

Reimplemented from operations_research::Stat.

Definition at line 230 of file stats.h.

◆ StartTimer()

void operations_research::TimeDistribution::StartTimer ( )
inline

Starts the timer in preparation of a StopTimerAndAddElapsedTime().

Definition at line 247 of file stats.h.

◆ StopTimerAndAddElapsedTime()

double operations_research::TimeDistribution::StopTimerAndAddElapsedTime ( )
inline

Adds the elapsed time since the last StartTimer() to the distribution and returns this time in CPU cycles.

Definition at line 251 of file stats.h.

◆ ValueAsString()

std::string operations_research::TimeDistribution::ValueAsString ( ) const
overridevirtual

Implemented by the subclasses.

Implements operations_research::DistributionStat.

Definition at line 210 of file stats.cc.


The documentation for this class was generated from the following files: