Some spring cleaning
This commit is contained in:
parent
78ccade17d
commit
91f241dba2
6 changed files with 26 additions and 26 deletions
|
|
@ -43,9 +43,9 @@ namespace GC
|
|||
m_chunk = chunk;
|
||||
}
|
||||
|
||||
GCEventType getType();
|
||||
std::time_t getTimeStamp();
|
||||
Chunk *getChunk();
|
||||
const char *TypeToString();
|
||||
GCEventType get_type();
|
||||
std::time_t get_time_stamp();
|
||||
Chunk *get_chunk();
|
||||
const char *type_to_string();
|
||||
};
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ namespace GC
|
|||
return m_instance;
|
||||
}
|
||||
|
||||
inline static Chunk *getAt(std::vector<Chunk *> &list, size_t n)
|
||||
inline static Chunk *get_at(std::vector<Chunk *> &list, size_t n)
|
||||
{
|
||||
auto iter = list.begin();
|
||||
if (!n)
|
||||
|
|
@ -56,7 +56,7 @@ namespace GC
|
|||
return *iter;
|
||||
}
|
||||
|
||||
inline static bool getProfilerMode() {
|
||||
inline static bool get_profiler_mode() {
|
||||
auto heap = Heap::the();
|
||||
return heap->m_profiler_enable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ namespace GC {
|
|||
inline static Profiler *m_instance = nullptr;
|
||||
std::vector<GCEvent *> m_events;
|
||||
|
||||
std::ofstream createFileStream();
|
||||
std::ofstream create_file_stream();
|
||||
|
||||
|
||||
public:
|
||||
static void record(GCEventType type);
|
||||
static void record(GCEventType type, Chunk *chunk);
|
||||
static void dumpTrace();
|
||||
static void dump_trace();
|
||||
};
|
||||
}
|
||||
|
|
@ -9,23 +9,23 @@
|
|||
namespace GC
|
||||
{
|
||||
|
||||
GCEventType GCEvent::getType()
|
||||
GCEventType GCEvent::get_type()
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
std::time_t GCEvent::getTimeStamp()
|
||||
std::time_t GCEvent::get_time_stamp()
|
||||
{
|
||||
return m_timestamp;
|
||||
}
|
||||
|
||||
Chunk *GCEvent::getChunk()
|
||||
Chunk *GCEvent::get_chunk()
|
||||
{
|
||||
return m_chunk;
|
||||
}
|
||||
|
||||
// Try to remove inline
|
||||
const char *GCEvent::TypeToString()
|
||||
const char *GCEvent::type_to_string()
|
||||
{
|
||||
switch (m_type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace GC
|
|||
// Check if there are any freed chunks large enough for current request
|
||||
for (size_t i = 0; i < heap->m_freed_chunks.size(); i++)
|
||||
{
|
||||
auto chunk = getAt(heap->m_freed_chunks, i);
|
||||
auto chunk = Heap::get_at(heap->m_freed_chunks, i);
|
||||
auto iter = heap->m_freed_chunks.begin();
|
||||
advance(iter, i);
|
||||
if (chunk->size > size)
|
||||
|
|
@ -177,7 +177,7 @@ namespace GC
|
|||
void Heap::mark(uintptr_t *start, const uintptr_t *end, vector<Chunk *> &worklist)
|
||||
{
|
||||
cout << "--- mark() was called ---\n" << endl;
|
||||
if (getProfilerMode())
|
||||
if (Heap::get_profiler_mode())
|
||||
Profiler::record(MarkStart);
|
||||
// To find adresses thats in the worklist
|
||||
for (; start <= end; start++)
|
||||
|
|
@ -204,7 +204,7 @@ namespace GC
|
|||
|
||||
if (!chunk->marked)
|
||||
{
|
||||
if (getProfilerMode())
|
||||
if (Heap::get_profiler_mode())
|
||||
Profiler::record(ChunkMarked, chunk);
|
||||
chunk->marked = true;
|
||||
cout << "Marked this chunk ^\n" << endl;
|
||||
|
|
@ -356,13 +356,13 @@ namespace GC
|
|||
std::vector<Chunk *> filtered;
|
||||
size_t i = 0;
|
||||
// filtered.push_back(heap->m_freed_chunks.at(i++));
|
||||
filtered.push_back(getAt(heap->m_freed_chunks, i++));
|
||||
filtered.push_back(Heap::get_at(heap->m_freed_chunks, i++));
|
||||
cout << filtered.back()->start << endl;
|
||||
for (; i < heap->m_freed_chunks.size(); i++)
|
||||
{
|
||||
auto prev = filtered.back();
|
||||
// auto next = heap->m_freed_chunks.at(i);
|
||||
auto next = getAt(heap->m_freed_chunks, i);
|
||||
auto next = Heap::get_at(heap->m_freed_chunks, i);
|
||||
auto p_start = (uintptr_t)(prev->start);
|
||||
auto p_size = (uintptr_t)(prev->size);
|
||||
auto n_start = (uintptr_t)(next->start);
|
||||
|
|
@ -398,7 +398,7 @@ namespace GC
|
|||
{
|
||||
set_profiler(true);
|
||||
|
||||
if (getProfilerMode())
|
||||
if (Heap::get_profiler_mode())
|
||||
Profiler::record(CollectStart);
|
||||
|
||||
cout << "DEBUG COLLECT\nFLAGS: ";
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@ namespace GC
|
|||
profiler->m_events.push_back(event);
|
||||
}
|
||||
|
||||
void Profiler::dumpTrace()
|
||||
void Profiler::dump_trace()
|
||||
{
|
||||
auto profiler = Profiler::the();
|
||||
auto start = profiler->m_events.begin();
|
||||
auto end = profiler->m_events.end();
|
||||
|
||||
std::ofstream fstr = profiler->createFileStream();
|
||||
std::ofstream fstr = profiler->create_file_stream();
|
||||
char buffer[22];
|
||||
std::tm *btm;
|
||||
std::time_t tt;
|
||||
|
|
@ -42,15 +42,15 @@ namespace GC
|
|||
{
|
||||
auto event = *start++;
|
||||
|
||||
tt = event->getTimeStamp();
|
||||
tt = event->get_time_stamp();
|
||||
btm = std::localtime(&tt);
|
||||
std::strftime(buffer, 22, "%a %T", btm);
|
||||
|
||||
fstr << "--------------------------------\n"
|
||||
<< buffer
|
||||
<< "\nEvent:\t" << event->TypeToString();
|
||||
<< "\nEvent:\t" << event->type_to_string();
|
||||
|
||||
chunk = event->getChunk();
|
||||
chunk = event->get_chunk();
|
||||
|
||||
if (chunk) {
|
||||
fstr << "\nChunk:\t" << chunk->start
|
||||
|
|
@ -61,7 +61,7 @@ namespace GC
|
|||
}
|
||||
}
|
||||
|
||||
std::ofstream Profiler::createFileStream()
|
||||
std::ofstream Profiler::create_file_stream()
|
||||
{
|
||||
std::time_t tt = std::time(NULL);
|
||||
std::tm *ptm = std::localtime(&tt);
|
||||
|
|
@ -69,8 +69,8 @@ namespace GC
|
|||
std::strftime(buffer, 32, "/profiler/log_%a_%H_%M_%S.txt", ptm);
|
||||
std::string filename(buffer);
|
||||
|
||||
//const std::string ABS_PATH = "/home/virre/dev/systemF/org/language/src/GC/";
|
||||
const std::string ABS_PATH = "/Users/valtermiari/Desktop/DV/Bachelors/code/language/src/GC";
|
||||
const std::string ABS_PATH = "/home/virre/dev/systemF/org/language/src/GC/";
|
||||
// const std::string ABS_PATH = "/Users/valtermiari/Desktop/DV/Bachelors/code/language/src/GC";
|
||||
std::string fullpath = ABS_PATH + filename;
|
||||
|
||||
std::ofstream fstr(fullpath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue