Results 1 to 4 of 4

Thread: Is this fps correct?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2017
    Posts
    5

    Question Is this fps correct?

    I am using OpenTK in vb.net.
    I am using elapsedticks to determine how many ticks have elapsed during the updateframe method.
    To measure my fps, I set up a stopwatch in my onUpdateFrame method:
    Code :
        Dim s As New Stopwatch
        Protected Overrides Sub OnUpdateFrame(e As FrameEventArgs)
            s.Start()
            Console.Write((s.ElapsedTicks).ToString + " ")
            s.Reset()
            MyBase.OnUpdateFrame(e)
            g.refresh(e.Time)
            If s.IsRunning Then s.Stop()
        End Sub

    My run function is:
    Code :
            g.Run(150.0, 150.0)


    The output is:


    Is this correct? Just 1 tick? Or zero?

  2. #2
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Also be aware that the resolution of the underlying timer may not be sufficient for measuring frametimes.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by mhagain View Post
    Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Also be aware that the resolution of the underlying timer may not be sufficient for measuring frametimes.

    The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Otherwise, the Stopwatch class uses the system timer to measure elapsed time. Use the Frequency and IsHighResolution fields to determine the precision and resolution of the Stopwatch timing implementation.
    -MSDN


    I added the following code in the constructor of the gamewindow to check the stopwatch details:
    Code :
     ' Display the timer frequency and resolution.
            If Stopwatch.IsHighResolution Then
                Console.WriteLine("Operations timed using the system's high-resolution performance counter.")
            Else
                Console.WriteLine("Operations timed using the DateTime class.")
            End If
     
            Dim frequency As Long = Stopwatch.Frequency
            Console.WriteLine("  Timer frequency in ticks per second = {0}", frequency)
            Dim nanosecPerTick As Long = 1000000000 / frequency
            Console.WriteLine("  Timer is accurate within {0} nanoseconds", nanosecPerTick)



    476 ns. Fast enough isn't it?

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2017
    Posts
    5
    Quote Originally Posted by mhagain View Post
    Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Also be aware that the resolution of the underlying timer may not be sufficient for measuring frametimes.

    The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Otherwise, the Stopwatch class uses the system timer to measure elapsed time. Use the Frequency and IsHighResolution fields to determine the precision and resolution of the Stopwatch timing implementation.
    -MSDN


    I added the following code in the constructor of the gamewindow to check the stopwatch details:
    Code :
     ' Display the timer frequency and resolution.
            If Stopwatch.IsHighResolution Then
                Console.WriteLine("Operations timed using the system's high-resolution performance counter.")
            Else
                Console.WriteLine("Operations timed using the DateTime class.")
            End If
     
            Dim frequency As Long = Stopwatch.Frequency
            Console.WriteLine("  Timer frequency in ticks per second = {0}", frequency)
            Dim nanosecPerTick As Long = 1000000000 / frequency
            Console.WriteLine("  Timer is accurate within {0} nanoseconds", nanosecPerTick)



    476 ns. Fast enough isn't it?

Similar Threads

  1. Replies: 0
    Last Post: 01-10-2017, 07:37 AM
  2. Getting the correct x y and z
    By Formatwizard in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 03-02-2011, 02:10 PM
  3. in MDI in MDI how do I get correct DC
    By REM in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-25-2002, 05:28 AM
  4. is it correct
    By schailan in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-29-2002, 07:25 AM
  5. Is this correct?
    By KRONOS in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-10-2000, 11:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean