0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

Set end of mark in constructor and test output to file on profile manager destructor

This commit is contained in:
Sergey Yagovtsev 2016-02-20 18:17:00 +03:00
parent 0d986a6464
commit 4d1c6a0228
2 changed files with 10 additions and 4 deletions

View File

@ -21,6 +21,10 @@ Block::Block(const char* _name, color_t _color, block_type_t _type) :
name(_name)
{
tick(begin);
if (this->type == BLOCK_TYPE_MARK)
{
end = begin;
}
thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
}
@ -42,8 +46,4 @@ Block::~Block()
endBlock();
}
else{//for mark end equal begin
end = begin;
}
}

View File

@ -2,6 +2,7 @@
#include <thread>
#include <string.h>
#include <fstream>
using namespace profiler;
@ -77,7 +78,12 @@ ProfileManager::ProfileManager()
ProfileManager::~ProfileManager()
{
std::ofstream of("test.prof",std::fstream::binary);
for (auto* b : m_blocks){
uint16_t sz = b->size();
of.write((const char*)&sz, sizeof(uint16_t));
of.write(b->data(), b->size());
delete b;
}
}