Started working on a custom profiler
This commit is contained in:
parent
4f9aaaf8b4
commit
137687e446
8 changed files with 158 additions and 28 deletions
34
src/GC/lib/profiler.cpp
Normal file
34
src/GC/lib/profiler.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "chunk.hpp"
|
||||
#include "event.hpp"
|
||||
#include "heap.hpp"
|
||||
#include "profiler.hpp"
|
||||
|
||||
namespace GC {
|
||||
void Profiler::record(GCEventType type) {
|
||||
auto event = new GCEvent(type);
|
||||
auto profiler = Profiler::the();
|
||||
profiler->m_events.push_back(event);
|
||||
}
|
||||
|
||||
void Profiler::record(GCEventType type, Chunk *chunk) {
|
||||
auto event = new GCEvent(type, chunk);
|
||||
auto profiler = Profiler::the();
|
||||
profiler->m_events.push_back(event);
|
||||
}
|
||||
|
||||
void Profiler::printTrace(PrintTraceOptions opt) {
|
||||
auto profiler = Profiler::the();
|
||||
auto start = profiler->m_events.begin();
|
||||
auto end = profiler->m_events.end();
|
||||
while (start != end) {
|
||||
auto event = *start++;
|
||||
if (opt == Short)
|
||||
event->printShort();
|
||||
else
|
||||
event->printFull();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue