|
-
Dec 19th, 2003, 04:53 PM
#1
Thread Starter
Fanatic Member
[VB] Estimated Time Till Completion
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
VB Code:
'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
Last edited by jsun9; Dec 22nd, 2003 at 03:00 PM.
-
Dec 20th, 2003, 07:23 AM
#2
Lively Member
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
-
Dec 22nd, 2003, 03:59 PM
#3
Fanatic Member
This has better resolution (and less code)
VB 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"
-
Dec 23rd, 2003, 10:06 AM
#4
Thread Starter
Fanatic Member
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.
-
Dec 23rd, 2003, 11:43 PM
#5
Lively Member
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
-
Dec 26th, 2003, 12:16 PM
#6
Hyperactive Member
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...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 27th, 2003, 03:26 AM
#7
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|