本文整理汇总了C++中Stat::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Stat::name方法的具体用法?C++ Stat::name怎么用?C++ Stat::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stat
的用法示例。
在下文中一共展示了Stat::name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coreStats
ProcStats::ProcStats(AggregateStat* parentStat, AggregateStat* _coreStats) : coreStats(_coreStats) {
uint32_t maxProcs = zinfo->lineSize;
lastUpdatePhase = 0;
// Check that coreStats are appropriate
assert(coreStats);
for (uint32_t i = 0; i < coreStats->size(); i++) {
Stat* s = coreStats->get(i);
AggregateStat* as = dynamic_cast<AggregateStat*>(s);
auto err = [s](const char* reason) {
panic("Stat %s is not per-core (%s)", s->name(), reason);
};
if (!as) err("not aggregate stat");
if (!as->isRegular()) err("irregular aggregate");
if (as->size() != zinfo->numCores) err("elems != cores");
}
// Initialize all the buffers
bufSize = StatSize(coreStats);
buf = gm_calloc<uint64_t>(bufSize);
lastBuf = gm_calloc<uint64_t>(bufSize);
// Create the procStats
procStats = new AggregateStat(true);
procStats->init("procStats", "Per-process stats");
for (uint32_t p = 0; p < maxProcs; p++) {
AggregateStat* ps = new AggregateStat(false);
const char* name = gm_strdup(("procStats-" + Str(p)).c_str());
ps->init(name, "Per-process stats");
for (uint32_t i = 0; i < coreStats->size(); i++) {
AggregateStat* as = dynamic_cast<AggregateStat*>(coreStats->get(i));
assert(as && as->isRegular());
ps->append(replStat(as->get(0), as->name(), as->desc()));
}
procStats->append(ps);
}
parentStat->append(procStats);
}
示例2: FilterStatsLevel
AggregateStat* FilterStatsLevel(const AggregateStat* src, const regex& filter, const char* prefix) {
string base = prefix? (string(prefix) + src->name() + ".") : ""; //if NULL prefix, omit our name (we're root)
vector<Stat*> children;
for (uint32_t i = 0; i < src->size(); i++) {
Stat* child = src->get(i);
if (AggregateStat* as = dynamic_cast<AggregateStat*>(child)) {
AggregateStat* fs = FilterStatsLevel(as, filter, base.c_str());
if (fs) children.push_back(fs);
} else {
string name = base + child->name();
if (regex_match(name, filter)) children.push_back(child);
}
}
if (children.size()) {
AggregateStat* res = new AggregateStat(src->isRegular());
res->init(src->name(), src->desc());
for (Stat* c : children) res->append(c);
return res;
} else {
return NULL;
}
}