#include "pls/internal/build_flavour.h"

#ifndef PLS_PROFILER_H
#define PLS_PROFILER_H
#if PLS_EASY_PROFILER_ENABLED

#include <easy/profiler.h>
#include <easy/arbitrary_value.h>

// 'bad' events that eat time
#define PROFILE_SYSCALL(msg) EASY_BLOCK(msg, profiler::colors::Red)
#define PROFILE_STEAL(msg) EASY_BLOCK(msg, profiler::colors::Orange)
#define PROFILE_SCHED(msg) EASY_BLOCK(msg, profiler::colors::Yellow)

// 'good' events that actually do work
#define PROFILE_WORK(msg) EASY_BLOCK(msg, profiler::colors::Green)

// heplers for saving/initializing
#define PROFILE_END_BLOCK EASY_END_BLOCK

#define PROFILE_SAVE(filename) profiler::dumpBlocksToFile(filename);
#define PROFILE_ENABLE EASY_PROFILER_ENABLE
#define PROFILE_MAIN_THREAD EASY_MAIN_THREAD
#define PROFILE_WORKER_THREAD EASY_THREAD("Worker")

#define PROFILE_VALUE(name, value) EASY_VALUE(name, value)

#else //ENABLE_EASY_PROFILER

// 'bad' events that eat time
#define PROFILE_SYSCALL(msg)
#define PROFILE_STEAL(msg)
#define PROFILE_SCHED(msg)

// 'good' events that actually do work
#define PROFILE_WORK(msg)

// heplers for saving/initializing
#define PROFILE_END_BLOCK

#define PROFILE_SAVE(filename)
#define PROFILE_ENABLE
#define PROFILE_MAIN_THREAD
#define PROFILE_WORKER_THREAD

#define PROFILE_VALUE(name, value)

#endif //ENABLE_EASY_PROFILER
#endif //PLS_PROFILER_H
