mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
More info in reader
This commit is contained in:
parent
be11666ea3
commit
4d1d66a405
@ -13,14 +13,28 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void printTree(const BlocksTree& tree, int level = 0)
|
||||
void printTree(const BlocksTree& tree, int level = 0, int parent_dur=0, int root_dur=0)
|
||||
{
|
||||
|
||||
if (tree.node){
|
||||
std::cout << std::string(level, '\t') << " "<< tree.node->getBlockName() << std::endl;
|
||||
}
|
||||
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);
|
||||
|
||||
printTree(i, level + 1, tree.node? tree.node->block()->duration() : 0, root_dur);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +57,8 @@ int main()
|
||||
std::cout << "Blocks count: " << blocks_counter << std::endl;
|
||||
std::cout << "dT = " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " usec" << std::endl;
|
||||
for (const auto & i : threaded_trees){
|
||||
// printTree(i.second,-1);
|
||||
std::cout << std::string(20, '=') << " thread "<< i.first << " "<< std::string(20, '=') << std::endl;
|
||||
printTree(i.second,-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -80,12 +80,69 @@ void renderThread(){
|
||||
frame();
|
||||
}
|
||||
}
|
||||
|
||||
void four()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
void five()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
void six()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
void three()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
four();
|
||||
five();
|
||||
six();
|
||||
}
|
||||
|
||||
void seven()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
void two()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
}
|
||||
|
||||
void one()
|
||||
{
|
||||
PROFILER_BEGIN_FUNCTION_BLOCK_GROUPED(profiler::colors::Red);
|
||||
two();
|
||||
three();
|
||||
seven();
|
||||
}
|
||||
|
||||
/*
|
||||
one
|
||||
two
|
||||
three
|
||||
four
|
||||
five
|
||||
six
|
||||
seven
|
||||
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
auto start = std::chrono::system_clock::now();
|
||||
PROFILER_ENABLE;
|
||||
|
||||
std::thread render = std::thread(renderThread);
|
||||
one();
|
||||
/*std::thread render = std::thread(renderThread);
|
||||
std::thread modelling = std::thread(modellingThread);
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
@ -98,6 +155,8 @@ int main()
|
||||
for(auto& t : threads){
|
||||
t.join();
|
||||
}
|
||||
*/
|
||||
|
||||
auto end = std::chrono::system_clock::now();
|
||||
auto elapsed =
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(end - start);
|
||||
|
Loading…
x
Reference in New Issue
Block a user