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


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

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


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

示例1: 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

示例2: 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

示例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


//.........这里部分代码省略.........
      //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;
  }
  std::cout << "== Here comes the stats ==" << std::endl;
  
  for (Stats::const_iterator it = data.begin();it!=data.end();++it) {
    const functionstat & f = it->second;
    if (f.count ==0 ) continue;
    std::cout << f.name << ":" << f.count << ":" << f.algorithm_size << ":" << bool(f.type==ProfilingData_FunctionType_MXFunction) << std::endl;
    /**
    for (int i=0;i<f.lines.size();++i) {
     const linestat &L = f.lines[i];
     std::cout << " " << i << ":" << L.count << ":" << L.total_time << ":" << L.code;
     if (L.dependency!=0) std::cout << "| call " << L.dependency << std::endl;
    }*/
  }
  
  // Calculate external_time and overhead_time
  for (Stats::iterator it = data.begin();it!=data.end();++it) {
    functionstat & f = it->second;
    if (f.type==ProfilingData_FunctionType_MXFunction) {
      f.overhead_time = f.total_time;
      for (std::vector<linestat>::const_iterator it2 = f.lines.begin();it2!=f.lines.end();++it2) {
        const linestat & l = *it2;
        f.overhead_time-= l.total_time;
        if (l.dependency) {
          f.external_time+= l.total_time;
        }
      }
    }
  }
  
  std::ofstream report ("prof.html");
  
  report << "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>\n<html xmlns='http://www.w3.org/1999/xhtml'>\n<head><script src='http://d3js.org/d3.v3.min.js'></script><script src='http://cpettitt.github.io/project/dagre-d3/v0.1.5/dagre-d3.min.js'></script>";
  
  report << "<style>"
"svg {"
开发者ID:tmmsartor,项目名称:casadi,代码行数:67,代码来源: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::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。