Dynamically estimating time needed to complete a program

S

Starx

I have a while loop in my program that is going to execute a very large
number of loops (well over 100000000). Sometimes this can take quite
some time for the computer to process so I'd like the program to supply
some sort of estimate as to how long the process may take. The number
of times the program must loop as well as the amount of proccessing
required for the block of code in the loop is entirely dependant on
choices the user makes before the processing begins so I can't just
print out a generic estimate. I'm not sure how to approach something
like this, is there a way for the computer to estimate using the time
it takes to complete a small number of loops (say 1000 or so)?
 
V

Victor Bazarov

Starx said:
I have a while loop in my program that is going to execute a very large
number of loops (well over 100000000). Sometimes this can take quite
some time for the computer to process so I'd like the program to supply
some sort of estimate as to how long the process may take. The number
of times the program must loop as well as the amount of proccessing
required for the block of code in the loop is entirely dependant on
choices the user makes before the processing begins so I can't just
print out a generic estimate. I'm not sure how to approach something
like this, is there a way for the computer to estimate using the time
it takes to complete a small number of loops (say 1000 or so)?

That's the way I'd do it. IOW, perform the first K loops (K < N), get the
clock readings (wall clock as well as CPU clock) and then print out the
estimate by extrapolating (multiplying by 'double(N)/K').

Also, it might be useful to indicate the progress somehow. If your app
does not have a user interface (interaction), you might want to create
a file named something like (progress_NN_percent) in the current (working)
directory, or have a periodic output to the log file (you do have a log
file, don't you?)

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top