menso111 Level: Trainee
 Registered: 19-10-2008 Posts: 1
|
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
|