eco2d/code/game/header/profiler.h

37 lines
752 B
C
Raw Normal View History

2021-05-13 12:17:44 +00:00
#pragma once
#include "system.h"
typedef enum {
2021-05-13 14:37:53 +00:00
PROF_TOTAL_TIME,
2021-05-13 12:17:44 +00:00
PROF_MAIN_LOOP,
2021-05-13 14:12:18 +00:00
2021-05-13 12:17:44 +00:00
PROF_WORLD_WRITE,
PROF_RENDER,
2021-05-13 13:44:08 +00:00
PROF_UPDATE_SYSTEMS,
2021-05-13 12:17:44 +00:00
PROF_ENTITY_LERP,
2021-05-13 13:44:08 +00:00
PROF_ENTITY_REMOVAL,
2021-05-13 12:17:44 +00:00
MAX_PROF,
PROF_FORCE_UINT8 = UINT8_MAX
} profiler_kind;
typedef struct {
profiler_kind id;
char const *name;
uint32_t num_invocations;
double start_time;
double delta_time;
double total_time;
} profiler;
void profiler_reset(profiler_kind id);
void profiler_start(profiler_kind id);
void profiler_stop(profiler_kind id);
void profiler_collate(void);
double profiler_delta(profiler_kind id);
char const *profiler_name(profiler_kind id);
#define profile(id) defer(profiler_start(id), profiler_stop(id))