本文整理汇总了C++中TrieNode::propagate_data_upwards方法的典型用法代码示例。如果您正苦于以下问题:C++ TrieNode::propagate_data_upwards方法的具体用法?C++ TrieNode::propagate_data_upwards怎么用?C++ TrieNode::propagate_data_upwards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrieNode
的用法示例。
在下文中一共展示了TrieNode::propagate_data_upwards方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Accumulate data from children into their parent.
void LocalState::TrieNode::propagate_data_upwards (void)
{
for (auto citer = children.begin(); citer != children.end(); citer++) {
TrieNode* child = citer->second;
child->propagate_data_upwards();
for (size_t i = 0; i < self_data.size(); i++)
path_data[i] += child->path_data[i];
invocations += child->invocations;
}
}
示例2: finalize
//.........这里部分代码省略.........
// Find the line-number column.
lineno_col = nullptr;
for (auto citer = table_data.begin(); citer != table_data.end(); citer++) {
Column* column = *citer;
string colname(column->name);
if (colname == "Line number" || colname == "Leaf line number")
lineno_col = column;
}
if (lineno_col == nullptr)
cerr << progname << ": Failed to find a \"Line number\" or \"Leaf line number\" column in the \"Functions\" table_data\n" << die;
if (lineno_col->type != Column::UINT64_T)
cerr << progname << ": The \""
<< lineno_col->name
<< "\" column does not contain integer data\n" << die;
// Find the invocation-count column.
invoke_col = nullptr;
for (auto citer = table_data.begin(); citer != table_data.end(); citer++) {
Column* column = *citer;
string colname(column->name);
if (colname == "Invocations")
invoke_col = column;
}
if (invoke_col == nullptr)
cerr << progname << ": Failed to find an \"Invocations\" column in the \"Functions\" table_data\n" << die;
if (invoke_col->type != Column::UINT64_T)
cerr << progname << ": The \""
<< invoke_col->name
<< "\" column does not contain integer data\n" << die;
// Construct a mapping from file name to ID and back.
size_t id = 1;
file_col = nullptr;
for (size_t i = 0; i < table_data.size(); i++)
if (table_data[i]->name == "File name" || table_data[i]->name == "Leaf file name") {
file_col = table_data[i];
break;
}
if (file_col == nullptr)
cerr << progname << ": Failed to find a \"File name\" or \"Leaf file name\" column in the \"Functions\" table_data\n" << die;
if (file_col->type != Column::STRING_T)
cerr << progname << ": The \""
<< file_col->name
<< "\" column does not contain string data\n" << die;
for (auto riter = file_col->string_data->begin();
riter != file_col->string_data->end();
riter++) {
string fname = *riter;
if (fname2id.find(fname) != fname2id.end())
continue;
fname2id[fname] = id;
id2fname[id] = fname;
id++;
}
// Construct a mapping from demangled function name or demangled call stack
// to ID and back.
id = 1;
func_col = nullptr;
for (size_t i = 0; i < table_data.size(); i++)
if (table_data[i]->name == "Demangled function name" || table_data[i]->name == "Demangled call stack") {
func_col = table_data[i];
break;
}
if (func_col == nullptr)
cerr << progname << ": Failed to find a \"Demangled function name\" or \"Demangled call stack\" column in the \"Functions\" table\n" << die;
if (func_col->type != Column::STRING_T)
cerr << progname << ": The \""
<< func_col->name
<< "\" column does not contain string data\n" << die;
size_t row = 0;
for (auto riter = func_col->string_data->begin();
riter != func_col->string_data->end();
riter++, row++) {
string func = *riter;
string func_only(func.substr(0, func.find(" # ")));
if (func2id.find(func_only) != func2id.end())
continue;
func2id[func_only] = id;
id2func[id] = func_only;
funcid2fnameid[id] = fname2id[(*file_col->string_data)[row]];
id++;
}
// Insert each call path into a trie forest. Compute inclusive and exclude
// metrics.
size_t func_col_num = func_col->number;
size_t nrows = func_col->string_data->size();
call_forest = new LocalState::TrieNode(this);
for (size_t r = 0; r < nrows; r++)
call_forest->insert(func_col_num, r);
auto citer = call_forest->children.begin();
if (citer != call_forest->children.end()) {
// Initialize the root to have all-zero data.
TrieNode* child = citer->second;
call_forest->self_data.resize(child->self_data.size(), 0);
call_forest->path_data.resize(child->path_data.size(), 0);
}
call_forest->propagate_data_upwards();
}