basic profiling
[pcsx_rearmed.git] / frontend / pcnt.h
CommitLineData
14dffdb7 1
2enum pcounters {
3 PCNT_ALL,
4 PCNT_GPU,
5 PCNT_SPU,
6 PCNT_CNT
7};
8
9extern unsigned int pcounters[PCNT_CNT];
10extern unsigned int pcounter_starts[PCNT_CNT];
11
12#define pcnt_start(id) \
13 pcounter_starts[id] = pcnt_get()
14
15#define pcnt_end(id) \
16 pcounters[id] += pcnt_get() - pcounter_starts[id]
17
18void pcnt_hook_plugins(void);
19
20static inline void pcnt_print(float fps)
21{
22 unsigned int total, gpu, spu, rem;
23 int i;
24
25 for (i = 0; i < PCNT_CNT; i++)
26 pcounters[i] >>= 10;
27
28 total = pcounters[PCNT_ALL];
29 gpu = pcounters[PCNT_GPU];
30 spu = pcounters[PCNT_SPU];
31 rem = total - gpu - spu;
32 if (!total)
33 total++;
34
35 printf("%2.1f %6u %6u %6u (%2d %2d %2d)\n", fps, gpu, spu, rem,
36 gpu * 100 / total, spu * 100 / total, rem * 100 / total);
37
38 memset(pcounters, 0, sizeof(pcounters));
39}
40
41static inline unsigned int pcnt_get(void)
42{
43 unsigned int val;
44#ifdef __ARM_ARCH_7A__
45 __asm__ volatile("mrc p15, 0, %0, c9, c13, 0"
46 : "=r"(val));
47#else
48 val = 0;
49#endif
50 return val;
51}
52