mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 00:31:02 +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)
|
name(_name)
|
||||||
{
|
{
|
||||||
tick(begin);
|
tick(begin);
|
||||||
|
if (this->type == BLOCK_TYPE_MARK)
|
||||||
|
{
|
||||||
|
end = begin;
|
||||||
|
}
|
||||||
thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
|
thread_id = std::hash<std::thread::id>()(std::this_thread::get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +46,4 @@ Block::~Block()
|
|||||||
|
|
||||||
endBlock();
|
endBlock();
|
||||||
}
|
}
|
||||||
else{//for mark end equal begin
|
|
||||||
end = begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace profiler;
|
using namespace profiler;
|
||||||
@ -77,7 +78,12 @@ ProfileManager::ProfileManager()
|
|||||||
|
|
||||||
ProfileManager::~ProfileManager()
|
ProfileManager::~ProfileManager()
|
||||||
{
|
{
|
||||||
|
std::ofstream of("test.prof",std::fstream::binary);
|
||||||
|
|
||||||
for (auto* b : m_blocks){
|
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;
|
delete b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user