 are effectivly equal
function IsCloseDouble([double]$a, [double]$b)
{
    return ([System.Math]::Abs($a - $b) -lt $script:fltEpsilon * 100)
}

#Check the performance requirements
function CheckPerformance([bool]$transparency, [double]$pVideoMemoryBandwidth)
{
    [double]$longerEdge = 0
    [double]$shorterEdge = 0
    if ($script:largestMonitorWidth -gt $script:largestMonitorHeight)
    {
        $longerEdge = $script:largestMonitorWidth
        $shorterEdge = $script:largestMonitorHeight
    }
    else
    {
        $longerEdge = $script:largestMonitorHeight
        $shorterEdge = $script:largestMonitorWidth
    }

    if (-not (IsCloseDouble ($shorterEdge * $script:assumedAspectRatio) $longerEdge))

    {
        [double]$area = $longerEdge * $shorterEdge
        $longerEdge = [System.Math]::Sqrt($area * $script:assumedAspectRatio)
        $shorterEdge = $longerEdge / $script:assumedAspectRatio
    }

    [int]$idx = 0
    if ($script:numMonitors -gt 1 -and $transparency)
    {
        $idx = 3
    }
    elseif($script:numMonitors -gt 1 -and -not $transparency)
    {
        $idx = 2
    }
    elseif($script:numMonitors -eq 1 -and $transparency)
    {
        $idx = 1
    }
    [double]$pixelsRequired = Evaluate $script:dragMovePolynomials[$idx] $longerEdge
    [double]$gpuTimePerFrame = ($script:bytesPerPixel * $pixelsRequired) / $pVideoMemoryBandwidth
    [double]$gpuTimePerSecond = $gpuTimePerFrame * $script:targetFramesPerSecond
    return $gpuTimePerSecond -le $script:gpuBudget
}

#Compute the lowest passing performance value
function ComputeForLowestPassingPerformance([bool]$transparency)
{
    [long]$top = 5000
    [long]$bottom = 0

    do
    {
        [double]$douVal = ($bottom + ($top - $bottom) / 2) * 1024 * 1024
        #$perf = CheckPerformance $transparency $douVal
        if (CheckPerformance $transparency $douVal)
        {
             $top = $top - (($top - $bottom) / 2)
        }
        else
        {
            $bottom = $# Copyright  2008, Microsoft Corporation. All rights reserved.


. .\CL_Utility.ps1
. .\CL_Invocation.ps1

Import-LocalizedData -BindingVariable localizationString -FileName CL_LocalizationData

Write-DiagProgress -activity $localizationString.winSatResolve_progress

[string]$fileName = "DisplayAssessment.xml"

[string]$winSatCmd = GetSystemPath "WinSat.exe"
SyncInvoke $winSatCmd "dwm -xml $fileName" $true

if((-not([String]::IsNullOrEmpty($fileName))) -and (Test-Path $fileName))
{
    Update-DiagReport -file $fileName -id UpdatedAssessmentFile -name $localizationString.updatedAssessmentFile_name -description $localizationString.assessmentFile_description -Verbosity Informational
}
