From c6c09dbe3294f7d38a8b75d55d49ed06cc8d3b57 Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Wed, 24 Feb 2016 06:30:13 +0300 Subject: [PATCH] Added reader example --- reader/CMakeLists.txt | 20 ++++++++++++++++++++ reader/main.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 reader/CMakeLists.txt create mode 100644 reader/main.cpp diff --git a/reader/CMakeLists.txt b/reader/CMakeLists.txt new file mode 100644 index 0000000..622cc09 --- /dev/null +++ b/reader/CMakeLists.txt @@ -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}) \ No newline at end of file diff --git a/reader/main.cpp b/reader/main.cpp new file mode 100644 index 0000000..74eab41 --- /dev/null +++ b/reader/main.cpp @@ -0,0 +1,43 @@ +#include "profiler/profiler.h" +#include +#include +#include + +template +struct tree +{ + typedef tree tree_t; + tree_t* parent; +}; + +int main() +{ + std::ifstream inFile("test.prof", std::fstream::binary); + + if (!inFile.is_open()){ + return -1; + } + + std::list 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; +}