def get_time_estimator(total):
t1 = time.time()<EOL>count = [<NUM_LIT:0>]<EOL>def estimate_needed_time(step=<NUM_LIT:1>):<EOL><INDENT>count[<NUM_LIT:0>] += step<EOL>t2 = time.time()<EOL>t3 = <NUM_LIT:1.0> * (t2 - t1) / count[<NUM_LIT:0>] * (total - count[<NUM_LIT:0>])<EOL>return t3, t3 + t1<EOL><DEDENT>return estimate_needed_time<EOL>
Given a total amount of items to compute, return a function that,
    if called every time an item is computed (or every step items are computed)
    will give a time estimation for how long it will take to compute the whole
    set of itmes. The function will return two values: the first is the number
    of seconds that are still needed to compute the whole set, the second value
    is the time in the future when the operation is expected to end.