~vladh/peony

peony/src/debug.hpp -rw-r--r-- 847 bytes
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#pragma once

#include <chrono>
namespace chrono = std::chrono;
#include "constants.hpp"
#include "types.hpp"

chrono::steady_clock::time_point debug_start_timer();
real64 debug_end_timer(chrono::steady_clock::time_point t0);

#if USE_TIMERS
  #define START_TIMER(name) \
    auto debug_timerstart_##name = debug_start_timer();

  #define END_TIMER_MIN(name, min_duration_ms) \
    { \
      real64 duration = debug_end_timer(debug_timerstart_##name); \
      if (duration >= min_duration_ms) { \
        logs::info("Timer %s took %0.fms", #name, duration); \
      } \
    }

  #define END_TIMER(name) END_TIMER_MIN(name, 0)
#else
  #define START_TIMER(name)
  #define END_TIMER_MIN(name, min_duration_ms)
  #define END_TIMER(name)
#endif