ProfileStats Class Reference
Collaboration diagram for ProfileStats:

Classes

struct  ProfileStatsEntry
 
struct  ReverseSecondComparator
 

Public Member Functions

void AccStats (const char *function_name, double elapsed)
 
 ~ProfileStats ()
 

Private Attributes

std::unordered_map< const char *, ProfileStatsEntrymap_
 

Detailed Description

Definition at line 29 of file timer.cc.

Constructor & Destructor Documentation

◆ ~ProfileStats()

~ProfileStats ( )
inline

Definition at line 41 of file timer.cc.

References rnnlm::i, KALDI_LOG, and ProfileStats::map_.

41  {
42  // This map makes sure we agglomerate the time if there were any duplicate
43  // addresses of strings.
44  std::unordered_map<std::string, double> total_time;
45  for (auto iter = map_.begin(); iter != map_.end(); iter++)
46  total_time[iter->second.name] += iter->second.total_time;
47 
48  ReverseSecondComparator comp;
49  std::vector<std::pair<std::string, double> > pairs(total_time.begin(),
50  total_time.end());
51  std::sort(pairs.begin(), pairs.end(), comp);
52  for (size_t i = 0; i < pairs.size(); i++) {
53  KALDI_LOG << "Time taken in " << pairs[i].first << " is "
54  << std::fixed << std::setprecision(2) << pairs[i].second << "s.";
55  }
56  }
std::unordered_map< const char *, ProfileStatsEntry > map_
Definition: timer.cc:76
#define KALDI_LOG
Definition: kaldi-error.h:153

Member Function Documentation

◆ AccStats()

void AccStats ( const char *  function_name,
double  elapsed 
)
inline

Definition at line 31 of file timer.cc.

References ProfileStats::map_.

Referenced by Profiler::~Profiler().

31  {
32  std::unordered_map<const char*, ProfileStatsEntry>::iterator
33  iter = map_.find(function_name);
34  if (iter == map_.end()) {
35  map_[function_name] = ProfileStatsEntry(function_name);
36  map_[function_name].total_time = elapsed;
37  } else {
38  iter->second.total_time += elapsed;
39  }
40  }
std::unordered_map< const char *, ProfileStatsEntry > map_
Definition: timer.cc:76

Member Data Documentation

◆ map_

std::unordered_map<const char*, ProfileStatsEntry> map_
private

Definition at line 76 of file timer.cc.

Referenced by ProfileStats::AccStats(), and ProfileStats::~ProfileStats().


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