Jump to content

Loop estimated time of completion


Recommended Posts

Hi guys,

I have a loop function which takes values from one array into another array based on a number of If Then conditions.

The original array can be of variable size so it is not a fixed array, hence sometimes it may take a long time and sometimes it can be quick, but I'd like to have an indication of an Estimated time of completion of the function.

Essentially I'd like to have a GUI label that shows a countdown of estimated time of completion. E.G. Ready in XX seconds. (where XX is an accurate countdown from start of loop to end of loop in terms of time taken to complete the loop function).

What's the best way to do this?

I played around with TimerInit() and TimerDiff() but I did not achieve the desirable effect.

Can someone comment on this please?

Cheers!

Link to comment
Share on other sites

Post your code and required context to run it. Else you can only get wild guesses.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Hi,

Take a look at the following example, the region 1 is what you have already in your script. I added some sleep to simulate the randomness of the process.

Local $hGUI = GUICreate("MyGUI")

Local $iMyLabel1 = GUICtrlCreateLabel("", 10, 10, 150, 15)

GUISetState(@SW_SHOW, $hGUI)

#region 1
Local $iSize = Random(10, 500, 1)

Local $aiArray[$iSize +1]

For $i = 0 To $iSize
    $aiArray[$i] = Random(0, 100, 1)
Next
#endregion

For $i = 0 To $iSize
    Sleep(Random(10, 100, 1))

    GUICtrlSetData($iMyLabel1, "Reading index " & $i & " of " & $iSize & ".")

    ConsoleWrite($aiArray[$i] & @CrLf)
Next
For the estimated time, you will have to think how you can do it, it's only maths.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

3.) use a progress(bar) and set ubound(yourarray) as 100%.

for the time calculation, just measure the time needed for one array element and multiply it with ubound

Edited by Edano

[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...