mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
Set end of mark in constructor and test output to file on profile manager destructor
This commit is contained in:
parent
0d986a6464
commit
4d1c6a0228
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user