[BROWSEUI][DEVMGR][EXPLORER][NTGDI][NTOBJSHEX][NTVDM][SETUPAPI] Remove/comment out...
[reactos.git] / subsystems / mvdm / ntvdm / clock.c
index 84d6391..b347b34 100644 (file)
@@ -38,8 +38,6 @@
 /* VARIABLES ******************************************************************/
 
 static LIST_ENTRY Timers;
-static ULONGLONG Cycles = 0ULL;
-static ULONGLONG CurrentIps = 20000000ULL; // 20 MIPS is a good estimate
 static LARGE_INTEGER StartPerfCount, Frequency;
 // static ULONG StartTickCount;
 static LARGE_INTEGER Counter;
@@ -47,17 +45,30 @@ static ULONG CurrentTickCount;
 static ULONGLONG LastCycles = 0ULL;
 static PHARDWARE_TIMER IpsTimer;
 
+ULONGLONG CurrentCycleCount = 0ULL;
+ULONGLONG CurrentIps = 20000000ULL; // 20 MIPS is a good estimate
+
 /* PRIVATE FUNCTIONS **********************************************************/
 
 static VOID FASTCALL IpsCallback(ULONGLONG ElapsedTime)
 {
-    CurrentIps = (Cycles - LastCycles) / ElapsedTime;
+#ifdef IPS_DISPLAY
+    static INT NumCalls = 0;
+#endif
+    
+    ULONGLONG NewIps = 10ULL * (CurrentCycleCount - LastCycles) / ElapsedTime;
+    CurrentIps = (CurrentIps + NewIps) >> 1;
 
 #ifdef IPS_DISPLAY
-    DPRINT1("NTVDM: %I64u Instructions Per Second\n", CurrentIps);
+    NumCalls++;
+    if (NumCalls == 10)
+    {
+        DPRINT1("NTVDM: %I64u Instructions Per Second\n", CurrentIps);
+        NumCalls = 0;
+    }
 #endif
 
-    LastCycles = Cycles;
+    LastCycles = CurrentCycleCount;
 }
 
 /* PUBLIC FUNCTIONS ***********************************************************/
@@ -81,7 +92,7 @@ VOID ClockUpdate(VOID)
         for (i = 0; VdmRunning && CpuRunning && (i < STEPS_PER_CYCLE); i++)
         {
             CpuStep();
-            ++Cycles;
+            ++CurrentCycleCount;
         }
 
         Entry = Timers.Flink;
@@ -205,16 +216,6 @@ VOID DestroyHardwareTimer(PHARDWARE_TIMER Timer)
     }
 }
 
-ULONGLONG GetCycleCount(VOID)
-{
-    return Cycles;
-}
-
-ULONGLONG GetCycleSpeed(VOID)
-{
-    return CurrentIps;
-}
-
 BOOLEAN ClockInitialize(VOID)
 {
     InitializeListHead(&Timers);
@@ -231,7 +232,7 @@ BOOLEAN ClockInitialize(VOID)
     /* Find the starting tick count */
     // StartTickCount = GetTickCount();
 
-    IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(1), IpsCallback);
+    IpsTimer = CreateHardwareTimer(HARDWARE_TIMER_ENABLED, HZ_TO_NS(10), IpsCallback);
     if (IpsTimer == NULL)
     {
         wprintf(L"FATAL: Cannot create IPS timer.\n");