Sign in to follow this  
Followers 0
michaelslamet

Counting time remaining

15 posts in this topic

Hi,

I need to process some files, can be hundreads at a time.

While processing those files, I plan to let the user know approx time remaining until processing finish,

but I have no idea how to do that.

I think something like:

$start_time = _now()

For $n = 1 to $number_of_files
    ; doing some processes here
    ; find out how long is the average time to process those files
    $approx_time_remaining = $average_time_process * ($number_of_files - $n)
    SplashTextOn("Please wait","Processing file number " & $n & @CRLF & "Approx time remaing: " & $approx_time_remaining ,300,50)
Next

Maybe using TimerInit() and calculate the diffferent using TimerDiff?

Share this post


Link to post
Share on other sites



Wouldn't a counter (e.g. "n of m files copied") be enough because the time you use it needs is just an approximation?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

michaelslamet,

I would do it like this:

$iCurr_Average= 0

$iPasses = Random(3, 10, 1)

For $i = 1 To $iPasses

    ; Get a timestamp
    $iBegin = TimerInit()
    ; A random Sleep
    Sleep(Random(1000, 5000, 1))
    ; How long was that
    $iThis_Time = Int(TimerDiff($iBegin))
    ConsoleWrite("Pass " & $i & " time: " & $iThis_Time & @CRLF) ; Just for display

    ; Calculate new average
    If $i > 1 Then
        $iCurr_Average = Int((($iCurr_Average * $i - 1) + $iThis_Time) / ($i + 1))
    Else
        $iCurr_Average = $iThis_Time
    EndIf
    ConsoleWrite("Calc average: " & $iCurr_Average & @CRLF) ; Just for display

    ; Calculate time remaining
    $iTime_Remaining = ($iPasses - $i) * $iCurr_Average
    ConsoleWrite("Remaining: " & $iTime_Remaining & @CRLF)

Next

All clear? :)

M23

2 people like this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi Water,

The files can be thousands and each file can take up to a minute, after the processing done, the user need to run it.

He usually run it using scheduler, so I think if he know when will the process done, it will be much better even it's only a approx.

Thanks :)

Share this post


Link to post
Share on other sites

Melba,

Helps a lot like always :) Thanks!

In the example, is the $iTime_Remaining in milliseconds?

What if I want to display it using HH:MM:SS format? So it will said something like: "Remaining: 00:01:55"

Share this post


Link to post
Share on other sites

As I have seen Melbas code perfectly solves the problem. The more files were copied the more accurate the calculation gets.

So: Stick with Melbas solution.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

michaelslamet,

 

is the $iTime_Remaining in milliseconds?

To the accuracy you require - yes. :)

 

What if I want to display it using HH:MM:SS format?

You do some maths to convert it! :D

Or....

You use the

_TicksToTime function to do it - look in the Helpfile for details. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

_TicksToTime seems great for this, thanks!

Thanks too, Water! :)

Share this post


Link to post
Share on other sites

Thanks, but I didn't do much to help you solve the problem ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

michaelslamet,

Glad I could help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Water: every help, no matter how big or small, is a help :)

Melba: you help newbie like me all the time :)

Share this post


Link to post
Share on other sites

michaelslamet,

That is what the forum is all about. I hope that you will be able to help others soon. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

If you notice, I try to help in few thread, but it's hard to find threads that can be solved using my (very) low skill :P

Share this post


Link to post
Share on other sites

The more you code the more you know the more you can help others. It's a "long and winding road" as one of my favorite bands would have sung.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Water: yes, thank you for remind me :)

I can see my AutoIT skill improve over time since I start using it few years ago :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0