testing testing...
This commit is contained in:
parent
fda9e6728f
commit
e51ba7679b
10 changed files with 933 additions and 42 deletions
|
|
@ -2,12 +2,31 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
|
||||
#include "chunk.hpp"
|
||||
#include "event.hpp"
|
||||
|
||||
// #define FunctionCallTypes
|
||||
// #define ChunkOpsTypes
|
||||
|
||||
namespace GC {
|
||||
|
||||
enum RecordOption
|
||||
{
|
||||
FunctionCalls = (GC::AllocStart | GC::CollectStart | GC::MarkStart | GC::SweepStart),
|
||||
ChunkOps = (GC::ChunkMarked | GC::ChunkSwept | GC::ChunkFreed | GC::NewChunk | GC::ReusedChunk),
|
||||
AllOps = ~0
|
||||
};
|
||||
|
||||
struct ProfilerEvent
|
||||
{
|
||||
uint m_n {1};
|
||||
const GCEventType m_type;
|
||||
|
||||
ProfilerEvent(GCEventType type) : m_type(type) {}
|
||||
};
|
||||
|
||||
class Profiler {
|
||||
private:
|
||||
Profiler() {}
|
||||
|
|
@ -17,31 +36,27 @@ namespace GC {
|
|||
delete c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of the Profiler singleton.
|
||||
* If m_instance is the nullptr and the profiler
|
||||
* is not initialized yet, initialize it and return
|
||||
* the pointer to it. Otherwise return the previously
|
||||
* initialized pointer.
|
||||
*
|
||||
* @returns The pointer to the profiler singleton.
|
||||
*/
|
||||
static Profiler *the()
|
||||
{
|
||||
if (m_instance)
|
||||
return m_instance;
|
||||
m_instance = new Profiler();
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
static Profiler &the();
|
||||
inline static Profiler *m_instance {nullptr};
|
||||
std::vector<GCEvent *> m_events;
|
||||
ProfilerEvent *m_last_prof_event {new ProfilerEvent(HeapInit)};
|
||||
std::vector<ProfilerEvent *> m_prof_events;
|
||||
RecordOption flags;
|
||||
|
||||
static void record_data(GCEvent *type);
|
||||
std::ofstream create_file_stream();
|
||||
std::string get_log_folder();
|
||||
static void dump_trace();
|
||||
static void dump_prof_trace();
|
||||
static void dump_chunk_trace();
|
||||
// static void dump_trace_short();
|
||||
// static void dump_trace_full();
|
||||
static void print_chunk_event(GCEvent *event, char buffer[22]);
|
||||
static const char *type_to_string(GCEventType type);
|
||||
|
||||
public:
|
||||
static RecordOption log_options();
|
||||
static void set_log_options(RecordOption flags);
|
||||
static void record(GCEventType type);
|
||||
static void record(GCEventType type, size_t size);
|
||||
static void record(GCEventType type, Chunk *chunk);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue