Jlm
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
jlm::util::StatisticsCollector Class Referencefinal

#include <Statistics.hpp>

Collaboration diagram for jlm::util::StatisticsCollector:
Collaboration graph
[legend]

Classes

class  StatisticsIterator
 

Public Types

using StatisticsRange = IteratorRange< StatisticsIterator >
 

Public Member Functions

 StatisticsCollector ()
 
 StatisticsCollector (StatisticsCollectorSettings settings)
 
const StatisticsCollectorSettingsGetSettings () const noexcept
 
StatisticsRange CollectedStatistics () const noexcept
 
size_t NumCollectedStatistics () const noexcept
 
bool IsDemanded (Statistics::Id id) const noexcept
 
bool IsDemanded (const Statistics &statistics) const noexcept
 
void CollectDemandedStatistics (std::unique_ptr< Statistics > statistics)
 
std::unique_ptr< StatisticsreleaseStatistic (Statistics::Id id)
 
void PrintStatistics ()
 Print collected statistics to file. If no statistics have been collected, this is a no-op.
 
File createOutputFile (std::string fileNameSuffix, bool includeCount=false)
 

Private Attributes

StatisticsCollectorSettings Settings_
 
std::vector< std::unique_ptr< Statistics > > CollectedStatistics_
 
std::unordered_map< std::string, size_t > OutputFileCounter_
 

Detailed Description

Collects and prints statistics.

Definition at line 443 of file Statistics.hpp.

Member Typedef Documentation

◆ StatisticsRange

Definition at line 513 of file Statistics.hpp.

Constructor & Destructor Documentation

◆ StatisticsCollector() [1/2]

jlm::util::StatisticsCollector::StatisticsCollector ( )
inline

Definition at line 515 of file Statistics.hpp.

◆ StatisticsCollector() [2/2]

jlm::util::StatisticsCollector::StatisticsCollector ( StatisticsCollectorSettings  settings)
inlineexplicit

Definition at line 518 of file Statistics.hpp.

Member Function Documentation

◆ CollectDemandedStatistics()

void jlm::util::StatisticsCollector::CollectDemandedStatistics ( std::unique_ptr< Statistics statistics)
inline

Add statistics to collected statistics. A statistics is only added if it is demanded.

Parameters
statisticsThe statistics to collect.
See also
StatisticsCollectorSettings::IsDemanded()

Definition at line 575 of file Statistics.hpp.

◆ CollectedStatistics()

StatisticsRange jlm::util::StatisticsCollector::CollectedStatistics ( ) const
inlinenoexcept

Definition at line 529 of file Statistics.hpp.

◆ createOutputFile()

File jlm::util::StatisticsCollector::createOutputFile ( std::string  fileNameSuffix,
bool  includeCount = false 
)

Creates a unique file name in the statistics and debug output directory. If a module name is specified in the settings, it is included in the file name. If a unique string is specified in the settings, it is also included. Lastly the given fileNameSuffix is used as the suffix for the file, including an optional counter if includeCount is true.

If the specified output directory does not exist, it is created.

Parameters
fileNameSuffixthe output file name suffix, e.g., "statistics.log"
includeCountinclude a counter per suffix, to avoid naming collisions
Returns
a file representing the new output file
Exceptions
jlm::util::errorin any of the following cases:
  • no output directory has been specified in the StatisticsCollectorSettings
  • any issues occur with creating the output directory
  • the resulting output file already exists

Definition at line 183 of file Statistics.cpp.

◆ GetSettings()

const StatisticsCollectorSettings & jlm::util::StatisticsCollector::GetSettings ( ) const
inlinenoexcept

Definition at line 523 of file Statistics.hpp.

◆ IsDemanded() [1/2]

bool jlm::util::StatisticsCollector::IsDemanded ( const Statistics statistics) const
inlinenoexcept

Checks if the pass statistics is demanded.

Parameters
statisticsThe statistics to check whether it is demanded.
Returns
True if statistics is demanded, otherwise false.

Definition at line 562 of file Statistics.hpp.

◆ IsDemanded() [2/2]

bool jlm::util::StatisticsCollector::IsDemanded ( Statistics::Id  id) const
inlinenoexcept

Checks statistics with the given id are demanded.

Parameters
idThe statistics id to check.
Returns
True if statistics with the given id are demanded, otherwise false.

Definition at line 549 of file Statistics.hpp.

◆ NumCollectedStatistics()

size_t jlm::util::StatisticsCollector::NumCollectedStatistics ( ) const
inlinenoexcept

Definition at line 536 of file Statistics.hpp.

◆ PrintStatistics()

void jlm::util::StatisticsCollector::PrintStatistics ( )

Print collected statistics to file. If no statistics have been collected, this is a no-op.

Exceptions
jlm::util::errorif there are statistics to print, but no output directory in settings

Definition at line 168 of file Statistics.cpp.

◆ releaseStatistic()

std::unique_ptr< Statistics > jlm::util::StatisticsCollector::releaseStatistic ( Statistics::Id  id)
inline

Extracts the last collected statistic with the given statistics id, removing it from the collector and returning an owned pointer.

Parameters
idthe id of the statistic to extract.
Returns
an owned pointer to the extracted statistic instance.
Exceptions
std::out_of_rangeif no statistic instance with the given id is present.

Definition at line 589 of file Statistics.hpp.

Member Data Documentation

◆ CollectedStatistics_

std::vector<std::unique_ptr<Statistics> > jlm::util::StatisticsCollector::CollectedStatistics_
private

Definition at line 635 of file Statistics.hpp.

◆ OutputFileCounter_

std::unordered_map<std::string, size_t> jlm::util::StatisticsCollector::OutputFileCounter_
private

Definition at line 638 of file Statistics.hpp.

◆ Settings_

StatisticsCollectorSettings jlm::util::StatisticsCollector::Settings_
private

Definition at line 634 of file Statistics.hpp.


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