本文整理汇总了C++中Stats::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Stats::find方法的具体用法?C++ Stats::find怎么用?C++ Stats::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stats
的用法示例。
在下文中一共展示了Stats::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
//.........这里部分代码省略.........