Results 1 to 7 of 7

Thread: [VB] Estimated Time Till Completion

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Lightbulb [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:
    1. 'Timer Refresh
    2. Dim RCTimer As String
    3. Dim RCTimerOLD As String
    4. Dim SecondsLeft As String
    5. Dim aveDiff As Long
    6. Dim aveDiffCount As Integer
    7. Dim iTotalTime As Integer
    8.  
    9. 'Progress Bar Refresh
    10. Dim pbPercent As String
    11. Dim pbTime As String
    12. Dim pbGBW As Integer
    13. Dim wHalf As Integer
    14.  
    15. Private Sub SampleFunction()
    16.  
    17. RC = 0
    18.  
    19. Do Until EOF(1)
    20.   UpdateProgressBar RC 'Call Function
    21.  
    22.   Seek #1, ((RC * RecordLength) + 1)
    23.   Get #1, , Record
    24.  
    25.   RC = RC + 1
    26.   RCTimer = RC
    27. Loop
    28.  
    29. End Sub
    30.  
    31. Private Sub tmrProgressBar_Timer()
    32.     Difference = Val(RCTimer) - Val(RCTimerOLD)
    33.     aveDiff = aveDiff + Difference
    34.     If aveDiff <> 0 Then aveDiffCount = aveDiffCount + 1
    35.     Difference = Round((aveDiff / aveDiffCount), 0)
    36.    
    37.     LeftOvers = iFileNR - RCTimer
    38.     IntervalsLeft = LeftOvers / Difference
    39.     TimeLeft = IntervalsLeft * tmrProgressBar.Interval
    40.     tmpSecondsLeft = TimeLeft / 1000
    41.     SecondsLeft = Round(tmpSecondsLeft, 0)
    42.     RCTimerOLD = RCTimer
    43. End Sub
    44.  
    45. Private Sub UpdateProgressBar(RC As Long)
    46.    
    47.     'Time Remaining Display
    48.     If (Val(SecondsLeft) Mod 60) < 10 Then FormatedSeconds = "0" & (Val(SecondsLeft) Mod 60) Else FormatedSeconds = (Val(SecondsLeft) Mod 60)
    49.     NewTime = (Val(SecondsLeft) \ 60) & ":" & FormatedSeconds
    50.    
    51.     pbTime = NewTime
    52.        
    53. 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.

  2. #2
    Lively Member Something Else's Avatar
    Join Date
    Nov 2003
    Location
    Where Humboldt Intersects Carlson
    Posts
    99
    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

  3. #3
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    This has better resolution (and less code)

    VB Code:
    1. 'In module
    2. Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    3.  
    4. '-In procedure
    5. Dim lngStart As Long
    6.  
    7. '-Put at beging of Sub or Function
    8. lngStartCount = GetTickCount()
    9.  
    10. '-Put at end of Sub or Function
    11. '- Output time take for code excution in milliseconds.
    12. Debug.Print GetTickCount() - lngStart & " ms"

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525
    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.

  5. #5
    Lively Member Something Else's Avatar
    Join Date
    Nov 2003
    Location
    Where Humboldt Intersects Carlson
    Posts
    99
    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

  6. #6
    Hyperactive Member
    Join Date
    Feb 2003
    Location
    Grenada
    Posts
    346
    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.

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    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
  •  



Click Here to Expand Forum to Full Width