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:


    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:

        g.Run(150.0, 150.0)

The output is:

Is this correct? Just 1 tick? Or zero?

Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.elapsedticks(v=vs.110).aspx

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

[QUOTE=mhagain;1286207]Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.elapsedticks(v=vs.110).aspx

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

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:


 ' 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?

[QUOTE=mhagain;1286207]Suggest that you read the documentation on the Stopwatch class: https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.elapsedticks(v=vs.110).aspx

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

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:


 ' 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?