Calculating remaining time for set of functions

Hello all,

I have written a toolkit for analysis of a large scientific data. For this purpose, I use several functions with too many loops and complex calculations. It would be great to have a panel which shows user the remaining time for a complete analysis (some kind of progress screen which appers on Microsoft Windows when we install something). I have some ideas but couldn't bring them together. Some hints? Thank you.

Best,
Emre
I'd start by executing the following on the Igor command line:
DisplayHelpTopic "Progress Windows"


You can also open the Progress Demo experiment which you can get to from the File->Example Experiments->Feature Demos 2 menu item.
Thanks for your comment. However, I had already seen that example and also the documantation about it. In my case it much more complicated. :(
Have you looked at the progress window XOP? http://www.igorexchange.com/project/progresswindow

Some time ago, I wrote a package to display a progress window. I will upload it as a project. Unfortunately, it is probably not usable in its present form, but you may get some ideas from it. I will give it some attention in the near future, if I get the chance.
tooprock wrote:
Thanks for your comment. However, I had already seen that example and also the documantation about it. In my case it much more complicated. :(

Unless you provide more information it's difficult to provide you with further help.

If you're looking for a way to calculate the remaining time, you'll probably need to use a timer to determine the length of time a certain percentage of the task takes and then extrapolate from there. For timing you can use the StartMSTimer/StopMSTimer operations. But as I'm sure you're seen before, progress windows that show you the time remaining are usually pretty unreliable, so you might want to consider whether it is worth your time to try to display the actual remaining time instead of just the % complete.
Not only is it difficult to calculate actual remaining time on a given machine, it will vary quite a lot from one machine to another, one operating system to another, and will depend a lot on what other things you have running on the computer.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
Not only is it difficult to calculate actual remaining time on a given machine, it will vary quite a lot from one machine to another, one operating system to another, and will depend a lot on what other things you have running on the computer.


You may be reading too much into tooprock's request. I didn't think the windows installer even attempted to tell you how much time is left. If I'm wrong it's because it's so innacurate I've tuned it out, but it's still nice to have some sign the computer hasn't frozen. In a scientific calculation with nested for loops you often get much more linear time vs. iterations behavior. There's no waiting for a registry lookup or interrupting and restarting random windows services. It can be very handy to have a rough visual estimate as to whether I should sit and wait for the calculation to finish, go find something else to do, or cut it off and run it over night.

I use the "poor man's progress bar" in a number of analysis packages: In Igorese it looks like:

print "calculating..."
for (index0 = 0; index0 < numsteps0; index0 ++ 1)
  if (mod(index0,100))             // optional only update progress every 100 iterations.
//    print (index0 / numsteps0 * 100), " percent complete"  // uncomment for a percentage estimate

  printf "."  // ASCII art progress bar.  comment out if using above line.
  endif

  [more nested loops go here]
//  Don't bother embedding any further down...
//  If you haven't seen the first update yet you're in for a long wait!
 
endfor


Replace index0 and numsteps0 with the variables you use in the outer loop. You need the mod check if the outermost loop is a large number of relatively fast iterations (printing and other display updates can be very slow relative to number crunching) and if it's a really small number of iterations, move the progress code into the next loop (slightly more complicated percent complete calculation based on two loop variables now).

I thought there was a graphical progress bar XOP, but perhaps I was just thinking of jtigor's "progress bar" package.
tooprock wrote:
Hello all,

I have written a toolkit for analysis of a large scientific data. For this purpose, I use several functions with too many loops and complex calculations. It would be great to have a panel which shows user the remaining time for a complete analysis (some kind of progress screen which appers on Microsoft Windows when we install something). I have some ideas but couldn't bring them together. Some hints? Thank you.

Best,
Emre


This is why when you install or update programs, often the "Time Remaining" will count down to zero seconds remaining and then sit there for many minutes. It's unreliable, but a fun way to make users happy.

Perhaps a better option is to provide a progress window that shows the percentage completed along with a counter that displays the seconds/minutes since the operation started. You could then use this data to continually update an ETA, but it may not always be accurate, especially if the data being crunched is irregular.
Thanks for all replies which were very helpful for me. I used  startMsTimer and stopMsTimer . What else I have done is calculating the remaining job as pencent since I know how many files I analyse. However, after I read your comments I decided to make a great change on working principle of the toolkit. This is how it looks like after all changes.

 // Calculate time required to analyse one file
    Variable refnumTimer, timeElapsed, timeasprogress
    // Read strings from list and set data folder accordingly
    Variable numDataFolders = ItemsInList(DataFolderList)
    Variable i
    NVAR perc = root:perc
    Variable progress = 0
    ControlUpdate/W=toolKIT/A
   
    for(i=0; i<numDataFolders; i +=1)
        refnumTimer = startMSTimer
        String nameCurDF = "root:RDDataFolder:" + StringFromList(i, DataFolderList)
        SetDataFolder nameCurDF
        AnalyseWIBSFiles()      // Main function which performs analysis
        timeElapsed = stopMSTimer(refnumTimer)
        timeasprogress = timeElapsed/1000000        // elapsed time as seconds
        //print "Last file took " + num2str(timeasprogress) + " seconds"        // We can see how long it takes to analyse a file
        progress += 1
        perc = (progress / numDataFolders) * 100
        ControlUpdate/W=toolKIT progress
        // change progress color to green.
        ValDisplay progress win=toolKIT, highColor= (26112,0,10240)
    endfor
Havent tested it emperically, but I could swear that lots of my iterative programs run much slower when I print the iterative variables out to keep track of run times.. that could be an illusion tho.

Also, didnt xkcd do a comic on this? yeah, there it is http://xkcd.com/612/
Anytime you print to the history or have Igor live-update graphs and tables, it will slow down a process, and quite significantly too.