PDA

Click to See Complete Forum and Search --> : [VB] Estimated Time Till Completion


jsun9
Dec 19th, 2003, 04:53 PM
I came up with this method of figuring out how long it'll take for my program to run through a ton or records (up to 500K). It works pretty well I think, but I'm interested in seeing what other ways people can come up with.

iFileNR = Number of Records In File


'Timer Refresh
Dim RCTimer As String
Dim RCTimerOLD As String
Dim SecondsLeft As String
Dim aveDiff As Long
Dim aveDiffCount As Integer
Dim iTotalTime As Integer

'Progress Bar Refresh
Dim pbPercent As String
Dim pbTime As String
Dim pbGBW As Integer
Dim wHalf As Integer

Private Sub SampleFunction()

RC = 0

Do Until EOF(1)
UpdateProgressBar RC 'Call Function

Seek #1, ((RC * RecordLength) + 1)
Get #1, , Record

RC = RC + 1
RCTimer = RC
Loop

End Sub

Private Sub tmrProgressBar_Timer()
Difference = Val(RCTimer) - Val(RCTimerOLD)
aveDiff = aveDiff + Difference
If aveDiff <> 0 Then aveDiffCount = aveDiffCount + 1
Difference = Round((aveDiff / aveDiffCount), 0)

LeftOvers = iFileNR - RCTimer
IntervalsLeft = LeftOvers / Difference
TimeLeft = IntervalsLeft * tmrProgressBar.Interval
tmpSecondsLeft = TimeLeft / 1000
SecondsLeft = Round(tmpSecondsLeft, 0)
RCTimerOLD = RCTimer
End Sub

Private Sub UpdateProgressBar(RC As Long)

'Time Remaining Display
If (Val(SecondsLeft) Mod 60) < 10 Then FormatedSeconds = "0" & (Val(SecondsLeft) Mod 60) Else FormatedSeconds = (Val(SecondsLeft) Mod 60)
NewTime = (Val(SecondsLeft) \ 60) & ":" & FormatedSeconds

pbTime = NewTime

End Sub

might help if I had the everything that's involved with it posted :o

Something Else
Dec 20th, 2003, 07:23 AM
It seems to calculate several values, but nothing ever seems to be displayed.

You seem to be useing a timer control.
What are the key values you want us to improve upon?

I just use GetTickCount before and after the process I want to time, then output the difference processed to a format of my chooseing.

-Lou

nkad
Dec 22nd, 2003, 03:59 PM
This has better resolution (and less code)


'In module
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

'-In procedure
Dim lngStart As Long

'-Put at beging of Sub or Function
lngStartCount = GetTickCount()

'-Put at end of Sub or Function
'- Output time take for code excution in milliseconds.
Debug.Print GetTickCount() - lngStart & " ms"

jsun9
Dec 23rd, 2003, 10:06 AM
how would i know when the end of the function would be reached? the point of this function is to determine how much longer it will take to complete the function.

Something Else
Dec 23rd, 2003, 11:43 PM
So, what you want is to take an estimated average of a process over a certain number of iterations, and project an estimation of how long it will take to complete the whole process?

-Lou

Protocol
Dec 26th, 2003, 12:16 PM
Simple....find the time taken to do ONE and then multiply it by the number of shizznit it has to do....

And that my friend is simple estimation...

Merri
Dec 27th, 2003, 03:26 AM
Calculating one is unaccurate. You should count every once and a while how much have been processed, how much time have gone and how much is yet to be processed. Shouldn't be overwhelming to code :)