mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
Add dumpBLocksToFile function
This commit is contained in:
parent
980edd631a
commit
82e9920e15
@ -226,6 +226,7 @@ namespace profiler
|
||||
void PROFILER_API beginBlock(Block* _block);
|
||||
void PROFILER_API endBlock();
|
||||
void PROFILER_API setEnabled(bool isEnable);
|
||||
unsigned int PROFILER_API dumpBlocksToFile(const char* filename);
|
||||
}
|
||||
|
||||
typedef uint8_t block_type_t;
|
||||
|
@ -22,6 +22,11 @@ extern "C"{
|
||||
{
|
||||
ProfileManager::instance().beginBlock(_block);
|
||||
}
|
||||
|
||||
unsigned int PROFILER_API dumpBlocksToFile(const char* filename)
|
||||
{
|
||||
return ProfileManager::instance().dumpBlocksToFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
SerilizedBlock::SerilizedBlock(Block* block):
|
||||
@ -85,14 +90,7 @@ 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;
|
||||
}
|
||||
//dumpBlocksToFile("test.prof");
|
||||
}
|
||||
|
||||
ProfileManager& ProfileManager::instance()
|
||||
@ -149,3 +147,20 @@ void ProfileManager::_internalInsertBlock(profiler::Block* _block)
|
||||
guard_lock_t lock(m_storedSpin);
|
||||
m_blocks.emplace_back(new SerilizedBlock(_block));
|
||||
}
|
||||
|
||||
unsigned int ProfileManager::dumpBlocksToFile(const char* filename)
|
||||
{
|
||||
std::ofstream of(filename, 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;
|
||||
}
|
||||
unsigned int size = (unsigned int)m_blocks.size();
|
||||
|
||||
m_blocks.clear();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
void beginBlock(profiler::Block* _block);
|
||||
void endBlock();
|
||||
void setEnabled(bool isEnable);
|
||||
unsigned int dumpBlocksToFile(const char* filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user