This a stupid thing to do?
Yes
 66%  [ 6 ]
Nope
 33%  [ 3 ]
Total Votes : 9

Hello, everyone! Been a while :3

Anyways, I'm trying to work on a small project, and I'm trying to calculate the estimated time remaining in a for loop.
I've been looking up different ways to do this, using different programming languages as examples.

Here's a python program I found that attempts to do this:

Code:

start_time = get the current time
for i in range(1, 101):
    # Do some work
    current_time = get the current time
    elapsed_time = current_time - start_time
    time_left = 100 * elapsed_time / i - elapsed_time
    print(time_left)


I tried to recreate it in TI-BASIC, and here's what I got so far..
(This is not optimized, It's more readable for my stupid brain to understand)

Code:

ClrHome:StartTmr→T
For(I,1,200
"do file operation crap here"
checkTmr(T→C
C-T→E
100*E/I-E
Output(1,1,I
Output(2,1,Ans
End


The code runs without errors, but it doesn't really wanna work. My end result I plan to have is the amount of SECONDS remaining for the function to complete.

Say if the loop was at 100 (50% done), and it took 3 seconds, the program would show 3 seconds left.
This kind of works. I just keyed this in, not sent from my TI 84 Plus CE. The Output with the has 5 spaces in it to cover the previous seconds.

ClrHome
1000 -> L
startTmr -> T
For(A,1,L
checkTmr(T) -> C
int(((C+1)/A)*(L-A)+1) -> B
Output(1,1,
Output(1,1,B)
End
I thought for a while and got a solution that works, this is an example program you can try out.


Code:

Input "End? ",P
ClrHome
Output(1,1,"NOW:
Output(2,1,"END:
Output(2,5,P
Output(3,1,"ETA:
startTmr->Z
Repeat checkTmr(Z:End
startTmr->T
For(I,1,P
Output(1,5,I
100I/P
If Ans and checkTmr(Z:Then
Output(3,5,toString(int(checkTmr(T)/(.01Ans))-checkTmr(T))+"s      //3 spaces after 's'
startTmr->Z
End:End


So far this program is pretty accurate.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement