#include "profiler/profiler.h" #include "profiler/reader.h" #include #include #include #include #include #include #include #include #include #include #include #include void printTree(const BlocksTree& tree, int level = 0, int parent_dur=0, int root_dur=0) { if (tree.node){ float percent = parent_dur ? float(tree.node->block()->duration()) / float(parent_dur)*100.0f : 100.0f; float rpercent = root_dur ? float(tree.node->block()->duration()) / float(root_dur)*100.0f : 100.0f; std::cout << std::string(level, '\t') << tree.node->getBlockName() << std::string(5 - level, '\t') << std::string(level, ' ') << percent << " | " << rpercent << " %" << std::endl; if (root_dur == 0){ root_dur = tree.node->block()->duration(); } } else{ root_dur = 0; } for (const auto& i : tree.children){ printTree(i, level + 1, tree.node? tree.node->block()->duration() : 0, root_dur); } } int main() { std::ifstream inFile("test.prof", std::fstream::binary); if (!inFile.is_open()){ return -1; } thread_blocks_tree_t threaded_trees; auto start = std::chrono::system_clock::now(); int blocks_counter = fillTreesFromFile("test.prof", threaded_trees); auto end = std::chrono::system_clock::now(); std::cout << "Blocks count: " << blocks_counter << std::endl; std::cout << "dT = " << std::chrono::duration_cast(end - start).count() << " usec" << std::endl; for (const auto & i : threaded_trees){ std::cout << std::string(20, '=') << " thread "<< i.first << " "<< std::string(20, '=') << std::endl; printTree(i.second,-1); } return 0; }