Can someone explain the following please?

hog

Well-known member
Joined
Mar 17, 2003
Messages
984
Location
UK
This is the text and function detailed in a book Im reading;

This function uses the system.environment.tickcount to retrieve the current tick of the processor clock (with the precision rate of a millisecond), so we can calculate the frame rate. Note this functionis not very accurate, but since we only use frame rate calculations to give us an idea of the speed at which were drawing the scene, and wont include it in our final games, we think using it is a valid approach
Code:
Public Function CalcFrameRate() As Integer

  Static FrameRate As Integer
  Static LastFrameRate As Integer
 
  Dim LastTick As Integer

  If System.Environment.TickCount - LastTick >= 1000 Then

    LastFrameRate = FrameRate
    FrameRate = 0
    LastTick = System.Environmetn.TickCount

  End If

  FrameRate += 1
  
  CalcFrameRate = LastFrameRate

End Function

In plain English, why is this not accurate?

Thnx
 
Back
Top