[IPLUG/AAX] remove IPlugAAX::SetParameterFromGUI()
[wdl/wdl-ol.git] / WDL / timing.c
blobe75baa7c09691e8695561987ed40931c336e7e01
1 #include "timing.h"
3 #ifdef TIMING
5 #include <stdio.h>
6 #ifdef _WIN32
7 #include <windows.h>
8 #endif
10 static struct {
11 __int64 st_time;
12 __int64 cycles,mint,maxt;
13 int foo;
14 int calls;
15 } timingInfo[64];
18 static void rdtsc(__int64 *t)
20 #ifdef _WIN64
21 LARGE_INTEGER now;
22 QueryPerformanceCounter(&now);
23 *t = now.QuadPart;
24 #elif !defined(_WIN32)
25 struct timeval tm={0,};
26 gettimeofday(&tm,NULL);
27 *t = ((__int64)tm.tv_sec)*1000000 + (__int64)tm.tv_usec;
28 #else
29 __asm
31 mov esi, t
32 _emit 0xf
33 _emit 0x31
34 mov [esi], eax
35 mov [esi+4], edx
37 #endif
40 void _timingInit(void)
42 memset(timingInfo,0,sizeof(timingInfo));
45 void _timingEnter(int which)
47 rdtsc(&timingInfo[which].st_time);
50 void _timingLeave(int which)
52 __int64 t;
53 rdtsc(&t);
54 t -= timingInfo[which].st_time;
55 if (!timingInfo[which].mint || t < timingInfo[which].mint) timingInfo[which].mint=t?t:1;
56 if (t > timingInfo[which].maxt) timingInfo[which].maxt=t;
57 timingInfo[which].cycles += t;
58 timingInfo[which].calls += 1;
61 void _timingPrint(void)
63 int x,p=0;
64 for (x = 0; x < sizeof(timingInfo)/sizeof(timingInfo[0]); x ++)
66 char buf[512];
67 if (timingInfo[x].calls)
69 p++;
70 sprintf(buf,"%d: %d calls, %.4f clocks/call (min=%.4f, max=%.4f). %.8f thingies of CPU time spent\n",
71 x,timingInfo[x].calls,(timingInfo[x].cycles/(double)timingInfo[x].calls),
72 (double)timingInfo[x].mint,(double)timingInfo[x].maxt,
73 (double)timingInfo[x].cycles
74 #if defined(_WIN64) || !defined(_WIN32)
75 / 1000000.0
76 #else
77 / (2.4*1000.0*1000.0*1000.0)
78 #endif
81 #ifdef _WIN32
82 OutputDebugString(buf);
83 #else
84 printf("%s",buf);
85 #endif
88 #ifdef _WIN32
89 if (!p) OutputDebugString("no calls to timing lib\n");
90 #else
91 if (!p) printf("no calls to timing lib\n");
92 #endif
94 timingInit();
97 #endif