RetroArch
performance_counters.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  * RetroArch is free software: you can redistribute it and/or modify it under the terms
6  * of the GNU General Public License as published by the Free Software Found-
7  * ation, either version 3 of the License, or (at your option) any later version.
8  *
9  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along with RetroArch.
14  * If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef _PERFORMANCE_COUNTERS_H
18 #define _PERFORMANCE_COUNTERS_H
19 
20 #include <stdint.h>
21 #include <boolean.h>
22 
23 #include <retro_common_api.h>
24 #include <libretro.h>
25 #include <features/features_cpu.h>
26 
28 
29 #ifndef MAX_COUNTERS
30 #define MAX_COUNTERS 64
31 #endif
32 
33 typedef struct rarch_timer
34 {
39  bool timer_end;
41 
43 
45 
46 unsigned retro_get_perf_count_rarch(void);
47 
48 unsigned retro_get_perf_count_libretro(void);
49 
51 
53 
54 void retro_perf_log(void);
55 
56 void rarch_perf_log(void);
57 
58 void rarch_perf_register(struct retro_perf_counter *perf);
59 
60 #define performance_counter_init(perf, name) \
61  perf.ident = name; \
62  if (!perf.registered) \
63  rarch_perf_register(&perf)
64 
65 #define performance_counter_start_internal(is_perfcnt_enable, perf) \
66  if ((is_perfcnt_enable)) \
67  { \
68  perf.call_cnt++; \
69  perf.start = cpu_features_get_perf_counter(); \
70  }
71 
72 #define performance_counter_stop_internal(is_perfcnt_enable, perf) \
73  if ((is_perfcnt_enable)) \
74  perf.total += cpu_features_get_perf_counter() - perf.start
75 
82 #define performance_counter_start_plus(is_perfcnt_enable, perf) performance_counter_start_internal(is_perfcnt_enable, perf)
83 
90 #define performance_counter_stop_plus(is_perfcnt_enable, perf) performance_counter_stop_internal(is_perfcnt_enable, perf)
91 
93 
95 
97 
99 
101 
103 
105 
107 
109 
110 #endif
111 
void rarch_perf_register(struct retro_perf_counter *perf)
Definition: performance_counters.c:64
int64_t current
Definition: performance_counters.h:35
Definition: btstack_hid.c:110
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
struct rarch_timer rarch_timer_t
void rarch_timer_begin(rarch_timer_t *timer, uint64_t ms)
Definition: performance_counters.c:179
void rarch_perf_log(void)
Definition: performance_counters.c:108
unsigned retro_get_perf_count_libretro(void)
Definition: performance_counters.c:59
bool rarch_timer_is_running(rarch_timer_t *timer)
Definition: performance_counters.c:138
void retro_perf_log(void)
Definition: performance_counters.c:117
void rarch_timer_end(rarch_timer_t *timer)
Definition: performance_counters.c:152
unsigned retro_get_perf_count_rarch(void)
Definition: performance_counters.c:54
void rarch_timer_begin_new_time_us(rarch_timer_t *timer, uint64_t usec)
Definition: performance_counters.c:170
Definition: libretro.h:1612
Definition: performance_counters.h:33
void rarch_timer_tick(rarch_timer_t *timer)
Definition: performance_counters.c:123
bool timer_end
Definition: performance_counters.h:39
void performance_counter_register(struct retro_perf_counter *perf)
Definition: performance_counters.c:77
void performance_counters_clear(void)
Definition: performance_counters.c:86
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
bool timer_begin
Definition: performance_counters.h:38
bool rarch_timer_has_expired(rarch_timer_t *timer)
Definition: performance_counters.c:145
struct retro_perf_counter ** retro_get_perf_counter_libretro(void)
Definition: performance_counters.c:49
struct retro_perf_counter ** retro_get_perf_counter_rarch(void)
Definition: performance_counters.c:44
void rarch_timer_begin_new_time(rarch_timer_t *timer, uint64_t sec)
Definition: performance_counters.c:161
int64_t timeout_us
Definition: performance_counters.h:36
signed __int64 int64_t
Definition: stdint.h:135
int rarch_timer_get_timeout(rarch_timer_t *timer)
Definition: performance_counters.c:131
int64_t timeout_end
Definition: performance_counters.h:37
unsigned __int64 uint64_t
Definition: stdint.h:136