aboutsummaryrefslogtreecommitdiff
path: root/frontend/pcnt.h
diff options
context:
space:
mode:
authornotaz2010-11-19 19:22:13 +0200
committernotaz2010-11-19 19:22:13 +0200
commit14dffdb7a0457fc647103deafa5f1cac12e888fb (patch)
treedb0b1a22f9beaaf535ebab0e0fda6d795055d3a4 /frontend/pcnt.h
parentb60f2812208aa36dc8b9e8e90f02b608dafd0c00 (diff)
downloadpcsx_rearmed-14dffdb7a0457fc647103deafa5f1cac12e888fb.tar.gz
pcsx_rearmed-14dffdb7a0457fc647103deafa5f1cac12e888fb.tar.bz2
pcsx_rearmed-14dffdb7a0457fc647103deafa5f1cac12e888fb.zip
basic profiling
Diffstat (limited to 'frontend/pcnt.h')
-rw-r--r--frontend/pcnt.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/frontend/pcnt.h b/frontend/pcnt.h
new file mode 100644
index 0000000..57bc88a
--- /dev/null
+++ b/frontend/pcnt.h
@@ -0,0 +1,52 @@
+
+enum pcounters {
+ PCNT_ALL,
+ PCNT_GPU,
+ PCNT_SPU,
+ PCNT_CNT
+};
+
+extern unsigned int pcounters[PCNT_CNT];
+extern unsigned int pcounter_starts[PCNT_CNT];
+
+#define pcnt_start(id) \
+ pcounter_starts[id] = pcnt_get()
+
+#define pcnt_end(id) \
+ pcounters[id] += pcnt_get() - pcounter_starts[id]
+
+void pcnt_hook_plugins(void);
+
+static inline void pcnt_print(float fps)
+{
+ unsigned int total, gpu, spu, rem;
+ int i;
+
+ for (i = 0; i < PCNT_CNT; i++)
+ pcounters[i] >>= 10;
+
+ total = pcounters[PCNT_ALL];
+ gpu = pcounters[PCNT_GPU];
+ spu = pcounters[PCNT_SPU];
+ rem = total - gpu - spu;
+ if (!total)
+ total++;
+
+ printf("%2.1f %6u %6u %6u (%2d %2d %2d)\n", fps, gpu, spu, rem,
+ gpu * 100 / total, spu * 100 / total, rem * 100 / total);
+
+ memset(pcounters, 0, sizeof(pcounters));
+}
+
+static inline unsigned int pcnt_get(void)
+{
+ unsigned int val;
+#ifdef __ARM_ARCH_7A__
+ __asm__ volatile("mrc p15, 0, %0, c9, c13, 0"
+ : "=r"(val));
+#else
+ val = 0;
+#endif
+ return val;
+}
+