borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to rotate a drawing object)Next Topic (Get RGB) New Topic New Poll Post Reply
AndreaVB Forum : API : way to calculete lcd response time
Poster Message
menso111
Level: Trainee

Registered: 19-10-2008
Posts: 1

Ads by Lake Quincy Media
icon way to calculete lcd response time

this code can calculate the resonse time of a lcd monitor

The idea is clear and obvius, but we need some help

How to paint the screen in a sincronus api?
like teh program stop esecutiuon till the paint event is complete (on the screen)?

Code:

' the focus of this utility is to get the response time form a lc monitor


' GetTickCount returns the number of milliseconds since Windows started
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As Long

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Private Function Subtract(value As TimeSpan) As DateTime



Private Sub Form_Load()
MsgBox "Per esguire questo programma è necessario chiudere tutte le applicazioni che usano qualsiasi risorsa" & vbNewLine & _
"Meglio se avviate il sistema in modalità provvisoria o usate msconfig" & vbNewLine & _
"per avviare una configurazionbe minima, altrimenti il tempo intrinseco di esecuzione del programma può alterare i risultati"
Picture1.Top = 0: Picture1.Left = 0
Picture1.Width = Screen.Width
Picture1.Height = Screen.Height
End Sub



' usiamo la funzione timer di windows che sembra piu accurata
' in quanto retrae i millisecondi con 2 zeri dopo la virgola

'  FIRST WE  retrive te medium time the program take for esecute
'  so we can subract it from the tOTALtIME
'  the difference   TotalTime - MediumTime = "lcd reposnse time"
Private Sub CmdTest_Click()
Dim MediumTime As Single, MyTime As Single, TimeWeRepeat As Single
TimeWeRepeat = 600
    For e = 0 To TimeWeRepeat
        MyTime = Vai(True)
        MediumTime = MediumTime + MyTime
    Next
    
'  now we have  the medium time the program take for esecute
'  it will be more exact the more is big TimeWeRepeat
'  il trempo medio è il tempo necessario all'esecuzione del programma
'  esso sara tanto piu esatto quanto è maggiore TimeWeRepeat
    MediumTime = MediumTime / TimeWeRepeat
    Me.Caption = MediumTime
    

' da sotrarre al tempo di risposta globale
' ora facciamo la stessa procedura ma cambiamo ripetutamente colore allo schermo
' cercando di far in modo che l'esecuzione del programma continui
' SOLO DOPO CHE LO SCHERMO  è completamente aggiornato
      
' al tempo totale che il programma impiega a disegnare lo schermo
' sottraiamo MediumTime , cioè il tempo necessario al prog,
' e dovremmo così ottenere il tempo necessario al displat per cambiare colore


' se volessimo ottenere un valore piu reale possibile possiamo ripetere la fase 2
' n volte, sommando il tempo inmpiegato di volta in voilta,
' retrarre un tempo medio dividendo il tempo totale per n
' e ottendo il tempo di risposta dello schermo sottraendo a questo tempo
' il tempo doi esecuzione del programma

' cosa ci serve:
' un api che cambi colore allo schermo bloccando l'esecuzione del programma
' fino a che l'evento non sia completamente terminato, e che restituisca
' quindil'esecuzione al programma.


'Whatz we need :
' a api function that will paint the screen and stopping the program
' ezecution till the screen is fully painted
' the reurnbing execution to the calling program (this program)
     MyTime = Vai(False)
    LabelSecDiff.Caption = tempo
End Sub

Private Function Vai(CalcolaIlTempoMedio As Boolean) As Single
Dim i As Long, MillisecInitials As Long, Secinitials As Single, SecFinal  As Single
Dim e As Long


        LabelSecDiff.Caption = "":  'labelMilliSecDiff.Caption = ""
        Secinitials = Timer
            For i = 0 To 890000 '00
                If CalcolaIlTempoMedio = False Then
                        ' here we need to paint the screen
                        ' with a sincronus function
                        Call PainMyScreen(0, 255)
                
                

                End If
            Next
        Sleep 3  ' se no è troppo veloce
        ' la funzione timer "sbaglia" solo se il risultato è minore di 1 millisecondo
        ' in quanto in questo caso restituisce un valore negativo  per questo usiamo abs
        'LabelSecDiff.Caption = ((Timer - Secinitials) * 1000)
'        If CalcolaIlTempoMedio = True Then
'            Vai = CSng(Abs((Timer - Secinitials) * 1000))
'        Else
            Vai = CSng(Abs((Timer - Secinitials) * 1000))
'            LabelSecDiff.Caption = Vai
'        End If


End Function





Private Sub Colora(StartColor, EndColor)
Picture1.BackColor = StartColor
'Sleep 10
Picture1.BackColor = EndColor

' we need to return only after the painting is complete

' also we need to stop if the monitor is off

End Sub


19-10-2008 at 05:58 PM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 637
icon Re: way to calculete lcd response time

I don't think that it is possible to calculate the response time of an LCD using software, response time is a phisical feature of the panel and doesn't matter with painting window events, which more relates to your graphic card and GPU performance.

There is no feedback from your monitor.
All the signals that goes to your monitor are output signals, there is no way to know if your monitor has performed an operation or not.
Even if you don't connect a monitor to your VGA output you will calculate a time that is the time that windows uses to refresh the portion of screen you have drawn

by the way this is only my opinion

____________________________
AndreaVB

Ads by Lake Quincy Media
01-12-2008 at 03:56 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : API : way to calculete lcd response time
Previous Topic (How to rotate a drawing object)Next Topic (Get RGB) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder