aboutsummaryrefslogtreecommitdiff
path: root/Src/Winamp/TIMING.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Winamp/TIMING.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Winamp/TIMING.cpp')
-rw-r--r--Src/Winamp/TIMING.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/Src/Winamp/TIMING.cpp b/Src/Winamp/TIMING.cpp
new file mode 100644
index 00000000..905ce748
--- /dev/null
+++ b/Src/Winamp/TIMING.cpp
@@ -0,0 +1,77 @@
+/** (c) Nullsoft, Inc. C O N F I D E N T I A L
+ ** Filename:
+ ** Project:
+ ** Description:
+ ** Author:
+ ** Created:
+ **/
+
+#include "main.h"
+#include "timing.h"
+
+#ifdef TIMING
+#ifndef __alpha
+
+
+static struct {
+ unsigned int st_time[2];
+ unsigned int cycles;
+ unsigned int calls;
+} timingInfo[64];
+
+static int timingEnters;
+
+static void rdtsc(unsigned int t[2])
+{
+ __asm
+ {
+ mov esi, t
+ _emit 0xf
+ _emit 0x31
+ mov [esi], eax
+ mov [esi+4], edx
+ }
+}
+
+void _timingInit()
+{
+ memset(timingInfo,0,sizeof(timingInfo));
+}
+
+void _timingEnter(int which)
+{
+// if (!timingEnters++) __asm cli
+ rdtsc(timingInfo[which].st_time);
+}
+
+void _timingLeave(int which)
+{
+ unsigned int t[2];
+ rdtsc(t);
+// if (!--timingEnters) __asm sti
+ if (t[1]==timingInfo[which].st_time[1])
+ {
+ timingInfo[which].cycles += t[0]-timingInfo[which].st_time[0];
+ }
+ else
+ {
+ timingInfo[which].cycles += t[0]+(0xffffffff-timingInfo[which].st_time[0]);
+ }
+ timingInfo[which].calls++;
+}
+
+void _timingPrint()
+{
+ int x;
+ FILE *fp = fopen("C:\\timings.txt","a+t");
+ for (x = 0; x < sizeof(timingInfo)/sizeof(timingInfo[0]); x ++)
+ {
+ if (timingInfo[x].calls)
+ fprintf(fp,"%d: %d calls, %d clocks/call\n",x,timingInfo[x].calls,timingInfo[x].cycles/timingInfo[x].calls);
+ }
+ _timingInit();
+ fclose(fp);
+}
+
+#endif
+#endif