/* 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;
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 ***********************************************************/
for (i = 0; VdmRunning && CpuRunning && (i < STEPS_PER_CYCLE); i++)
{
CpuStep();
- ++Cycles;
+ ++CurrentCycleCount;
}
Entry = Timers.Flink;
}
}
-ULONGLONG GetCycleCount(VOID)
-{
- return Cycles;
-}
-
-ULONGLONG GetCycleSpeed(VOID)
-{
- return CurrentIps;
-}
-
BOOLEAN ClockInitialize(VOID)
{
InitializeListHead(&Timers);
/* 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");