mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
Added reader example
This commit is contained in:
parent
5dfb456176
commit
c6c09dbe32
20
reader/CMakeLists.txt
Normal file
20
reader/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
project(profiler_reader)
|
||||||
|
|
||||||
|
set(CPP_FILES
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
${CPP_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
#-DFULL_DISABLE_PROFILER
|
||||||
|
)
|
||||||
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
set(SPEC_LIB pthread)
|
||||||
|
endif(UNIX)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})
|
43
reader/main.cpp
Normal file
43
reader/main.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include "profiler/profiler.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <list>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct tree
|
||||||
|
{
|
||||||
|
typedef tree<T> tree_t;
|
||||||
|
tree_t* parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::ifstream inFile("test.prof", std::fstream::binary);
|
||||||
|
|
||||||
|
if (!inFile.is_open()){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<profiler::SerilizedBlock> blocksList;
|
||||||
|
while (!inFile.eof()){
|
||||||
|
uint16_t sz = 0;
|
||||||
|
inFile.read((char*)&sz, sizeof(sz));
|
||||||
|
if (sz == 0)
|
||||||
|
{
|
||||||
|
inFile.read((char*)&sz, sizeof(sz));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
char* data = new char[sz];
|
||||||
|
inFile.read((char*)&data[0], sz);
|
||||||
|
blocksList.emplace_back(sz, data);
|
||||||
|
}
|
||||||
|
for (auto& i : blocksList){
|
||||||
|
static auto thread_id = i.block()->thread_id;
|
||||||
|
//if (i.block()->thread_id == thread_id)
|
||||||
|
std::cout << i.block()->duration() << "\n";
|
||||||
|
//std::cout << i.getBlockName() << ":" << (i.block()->end - i.block()->begin)/1000 << " usec." << std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user