Jump to content

Calculating the FPS of a window


Recommended Posts

Hi guys

I'm tryign to design an application that will read the current FPS on a given window, however, The only way I can find to do it, is to evaluate the change in a given pixel over a second to determine whether or not the screen is actually changing. This being said, if that pixel doesnt change color for a few milliseconds, I may be missing out on a few counts that over all influences my check. Is there anyway that a script can be written to evaluate the frames of a given screen?

The code I have running now is:

#include <Misc.au3>

FileOpen("FPSdata.txt")

Global $color2
$count = 0

$avgCounter = 0
$avgTotal = 0
$avg = 0

$min = 100
$max = 0

$totalSeconds = 0

GUICreate("FPS",120,40)
GUICtrlCreateLabel("FPS=", 1, 10)
GUISetState(@SW_SHOW)

$label = GUICtrlCreateLabel($count, 27, 10)

Sleep(15000)

$timer = TimerInit()

Do
    $color = PixelGetColor(500, 700);enter the pixelcoordinates to check

    If $color <> $color2 Then
        $count += 1
        $color2 = $color
    EndIf

    $dif = TimerDiff($timer)

    If $dif > 1000 Then
        $totalSeconds += 1
        GUICtrlSetData($label, $count)
        if $count > 0 Then
            FileWriteLine("FPSdata.txt", $count)
            $avgTotal += $count
            $avgCounter += 1
            if $count > $max then 
                $max = $count 
            endif
            if $count < $min then 
                $min = $count 
            endif
        EndIf
        $count = 0
        $timer = TimerInit()
    EndIf
Until _IsPressed('1B')

$avg = $avgTotal / $avgCounter

FileWriteLine("FPSdata.txt", " ")
FileWrite("FPSdata.txt", "Avg = ")
FileWriteLine("FPSdata.txt", $avg)
FileWrite("FPSdata.txt", "Min = ")
FileWriteLine("FPSdata.txt", $min)
FileWrite("FPSdata.txt", "Max = ")
FileWriteLine("FPSdata.txt", $max)
FileWrite("FPSdata.txt", "Application ran for: ")
FileWrite("FPSdata.txt", $totalSeconds)
FileWrite("FPSdata.txt", " seconds.")

FileClose("FPSdata.txt")

any other ideas?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...