25 #include <unordered_map> 31 void AccStats(
const char *function_name,
double elapsed) {
32 std::unordered_map<const char*, ProfileStatsEntry>::iterator
33 iter =
map_.find(function_name);
34 if (iter ==
map_.end()) {
36 map_[function_name].total_time = elapsed;
38 iter->second.total_time += elapsed;
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;
49 std::vector<std::pair<std::string, double> > pairs(total_time.begin(),
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.";
67 bool operator () (
const std::pair<std::string, double> &a,
68 const std::pair<std::string, double> &b) {
69 return a.second > b.second;
76 std::unordered_map<const char*, ProfileStatsEntry>
map_;
82 g_profile_stats.
AccStats(name_, tim_.Elapsed());
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
std::unordered_map< const char *, ProfileStatsEntry > map_
ProfileStatsEntry(const char *name)
void AccStats(const char *function_name, double elapsed)
ProfileStats g_profile_stats