当前位置: 首页>>代码示例>>C++>>正文


C++ Stats::end方法代码示例

本文整理汇总了C++中Stats::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Stats::end方法的具体用法?C++ Stats::end怎么用?C++ Stats::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stats的用法示例。


在下文中一共展示了Stats::end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runStatMultipliers

int runStatMultipliers (Stats stats, Stats multipliers) {
    int totalEffect = 0;
    Stats statEffects = mergeStatMaps(stats, multipliers);
    //Sum values in statEffects map
    Stats::const_iterator it;
    for (it = statEffects.begin(); it != statEffects.end(); it++) {
        totalEffect += (*it).second;
    }

    return totalEffect;
}
开发者ID:lordcirth,项目名称:RPG,代码行数:11,代码来源:buffs.cpp

示例2: mergeStatMaps

//Multiply elements of *identical* maps together
Stats mergeStatMaps(Stats mapA, Stats mapB) {
    Stats::const_iterator itA, itB;
    itB = mapB.begin();
    Stats result;

    for (itA = mapA.begin(); itA != mapA.end(); itA++) {
        //Take key from A, and multiply values from A and B.
        result.emplace((*itA).first, (*itA).second * (*itB).second );

        itB++;
    }
    return result;
};
开发者ID:lordcirth,项目名称:RPG,代码行数:14,代码来源:buffs.cpp

示例3: writeStatsDebug

void writeStatsDebug(FILE* fdebug, const std::string& name, const Stats& stats)
{
	fprintf(fdebug, name.c_str());
	int pCount=0;
	for( Stats::const_iterator sit = stats.begin();
		sit != stats.end();
		++sit, ++pCount)
		fprintf(fdebug, "[%d] Ave=%4.2f:%4.2f:%4.2f:%4.2f::%4.2f:%4.2f, StDev=%4.2f:%4.2f:%4.2f:%4.2f::%4.2f:%4.2f\n", 
					pCount,
					sit->Ave[2], sit->Ave[3], sit->Ave[4], sit->Ave[5], sit->Ave[0], sit->Ave[1],
					sit->StDev[2], sit->StDev[3], sit->StDev[4], sit->StDev[5], sit->StDev[0], sit->StDev[1]
				);
}
开发者ID:KJCondron,项目名称:VideoWatcher,代码行数:13,代码来源:common_utils.cpp

示例4: main

int main(int argc, char* argv[])
{
    Stats data;
    if (argc < 1) {
        std::cerr << "Usage: " << argv[0] << "prof.log" << std::endl;
        return 1;
    }
    
  std::ifstream myfile (argv[1]);
  if (myfile.is_open())
  {
    while (!myfile.eof()) {
    ProfilingHeader hd;
    myfile.read(reinterpret_cast<char*>(&hd), sizeof(hd));
    switch (hd.type) {
     case (ProfilingData_Type_TIMELINE) : {
      ProfilingData_TIMELINE s;
      myfile.read(reinterpret_cast<char*>(&s), sizeof(s));
      Stats::iterator it = data.find(s.thisp);
      std::vector<linestat> & v = it->second.lines;
      v[s.line_number].count+=1;
      v[s.line_number].total_time+=s.local;
      //std::cout << s.thisp << ":" << s.line_number << "|" << s.local << "," << s.total << std::endl;
     }; break;
     case (ProfilingData_Type_SOURCE) : {
      ProfilingData_SOURCE s;
      myfile.read(reinterpret_cast<char*>(&s), sizeof(s));
      char sourceline[s.length+1];
      myfile.read(reinterpret_cast<char*>(&sourceline), s.length);
      Stats::iterator it = data.find(s.thisp);
      std::vector<linestat> & v = it->second.lines;
      linestat L;
      L.total_time = 0;
      L.count = 0;
      L.opcode = 0;
      L.dependency = 0;
      if (s.line_number-int(v.size())+1>0) {
        v.insert(v.end(),s.line_number-int(v.size())+1,L);
      }
      //std::cout << v.size() << s.line_number << std::endl;
      sourceline[s.length] = 0;
      v[s.line_number].code = sourceline;
      v[s.line_number].opcode = s.opcode;
      v[s.line_number].dependency = s.dependency;
      //std::cout << s.thisp << ":" << s.line_number << ": " << sourceline << std::endl;
     }; break;
     case (ProfilingData_Type_NAME) : {
      ProfilingData_NAME s;
      myfile.read(reinterpret_cast<char*>(&s), sizeof(s));
      char name[s.length+1];
      myfile.read(name, sizeof(char)*s.length);
      Stats::iterator it = data.find(s.thisp);
      if (it==data.end()) {
        functionstat f;
        f.count = 0;
        f.total_time = 0;
        f.external_time = 0;
        f.overhead_time = 0;
        data[s.thisp] = f;
        it = data.find(s.thisp);
      }
      name[s.length] = 0; // Null-terminated
      
      functionstat &f = it->second;
      f.name = name;
      f.algorithm_size = s.algorithm_size;
      f.type = s.type;
      
      f.inputs.resize(s.numin);
      //std::cout << name << std::endl;
      //std::cout << "n" << s.numin << "," << s.numout << std::endl;
      for (int i=0;i<s.numin;++i) {
        myfile.read(reinterpret_cast<char*>(&f.inputs[i]), sizeof(iostat));
      }
      f.outputs.resize(s.numout);
      for (int i=0;i<s.numout;++i) {
        myfile.read(reinterpret_cast<char*>(&f.outputs[i]), sizeof(iostat));
      }
     }; break;
     case (ProfilingData_Type_ENTRY) : {
      ProfilingData_ENTRY s;
      myfile.read(reinterpret_cast<char*>(&s), sizeof(s));
      Stats::iterator it = data.find(s.thisp);      
      it->second.count+=1;
      //std::cout << "Entry " << s.thisp << std::endl;
     }; break;
     case (ProfilingData_Type_EXIT) : {
      ProfilingData_EXIT s;
      myfile.read(reinterpret_cast<char*>(&s), sizeof(s));
      Stats::iterator it = data.find(s.thisp);
      it->second.total_time +=s.total;
      //std::cout << "Exit " << s.thisp << ": " << s.total << std::endl;
     }; break;
     default:
       std::cerr << "Unknown type in profile header: " << hd.type << std::endl;
    }
    }
  } else {
    std::cerr << "Unable to open file" << std::endl;
  }
//.........这里部分代码省略.........
开发者ID:tmmsartor,项目名称:casadi,代码行数:101,代码来源:profilereport.cpp

示例5: main_loop

void main_loop()
{

  while (true)
  {
    unsigned int maxLen = 4;
    // Reset all counters
    for (auto& ov: objectMap)
      ov.second.call<void>("clearStats");

    qi::os::msleep(interval * 1000);

    Stats stats;
    // Fetch stats from monitored objects and fill stats
    for(ObjectMap::value_type& ov: objectMap)
    {
      qi::ObjectStatistics os = ov.second.call<qi::ObjectStatistics>("stats");
      const std::string& serviceName = ov.first;
      for(qi::ObjectStatistics::value_type& s: os)
      {
        if (s.first == 83)
          continue; // hide clearstats
        std::string name = boost::lexical_cast<std::string>(s.first);
        if (!numeric)
        {
          qi::MetaObject mo = ov.second.metaObject();
          qi::MetaMethod* m = mo.method(s.first);
          if (m)
            name = m->name();
          else
          {
            qi::MetaSignal* sig = mo.signal(s.first);
            if (sig)
              name = sig->name();
            else
              name = name + "(??" ")"; // trigraph protect mode on
          }
        }
        maxLen = std::max(maxLen, (unsigned int)name.size());
        stats.push_back(std::make_pair(std::make_pair(serviceName, name), s.second));
      }
    }
    if (!full)
      maxLen = std::min(maxLen, 25u);
    // Now, sort
    std::sort(stats.begin(), stats.end(), StatCompare());
    // display
    std::cout << "MODULE" << std::string(maxLen + 2 - 6, ' ')
     << "METHOD" << std::string((full?maxServiceLength:17) + 2 - 6, ' ')
     << "  %CPU  " << "COUNT         "
     << "USER" << std::string(6*3 - 2, ' ')
     << "SYS " << std::string(6*3 - 2, ' ')
     << "WALL"
     << std::endl;
    for(const Stat& s: stats)
    {
      const qi::MethodStatistics& ms = s.second;
      std::string serviceName = s.first.first;
      std::string methodName = s.first.second;
      if (!full && serviceName.size() > 17)
        serviceName = serviceName.substr(0, 14) + "...";
      if (!full && methodName.size() > 25)
        methodName = methodName.substr(0, 22) + "...";
      std::string spacing(maxLen + 2 - methodName.size(), ' ');
      std::string spacing2((full?maxServiceLength:17) + 2 - serviceName.size(), ' ');

      std::cout << serviceName << spacing2 << methodName << spacing
        << std::setw(6) << (((ms.user().cumulatedValue() + ms.system().cumulatedValue()) * 100) / interval) << "% "
        << std::setw(3)
        << ms.count() << "x  "
        << us(ms.user().cumulatedValue() / (float)ms.count()) << ' ' << us(ms.user().minValue()) << ' ' << us(ms.user().maxValue())
        << "   "
        << us(ms.system().cumulatedValue() / (float)ms.count()) << ' ' << us(ms.system().minValue()) << ' ' << us(ms.system().maxValue())
        << "   "
        << us(ms.wall().cumulatedValue() / (float)ms.count()) << ' ' << us(ms.wall().minValue()) << ' ' << us(ms.wall().maxValue())
        << "   "
        << std::endl;
    }
  }
}
开发者ID:ZhaozhengPlus,项目名称:libqi,代码行数:80,代码来源:qitop.cpp


注:本文中的Stats::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。