def test_completion_stats(binning, target_time):
    'How long for 50,75,87.5, and 100% of tests to complete (as a percentage of target_time'
    # change run times to times of completion for each bin
    completion_bins = list()
    for bin in binning:
        time_accumulator.t = 0.0
        completion_bins.append(
            [time_accumulator(duration) for duration in bin]
            )
    #merge completion times for each bin
    completion_times = sum(completion_bins,[])
    completion_times.sort()
    #find the times for tests to complete
    end_time = completion_times[-1] # last element
    num_tests = len(completion_times)
    num50 = num_tests*50/100-1
    num75 = num_tests*75/100-1
    num87 = num_tests*875/1000-1 # 87.5%
    time_to_50 = time_to_75 = time_to_87 = time_to_100 = 0
    for n,ct in enumerate(completion_times):
        if n==num50:
            #found when 50% tests finished
            time_to_50 = ct
        if n==num75:
            #found when 75% tests finished
            time_to_75 = ct
        if n==num87:
            #found when 87.5% tests finished
            time_to_87 = ct
            break
    time_to_100 = end_time
            
    return [time_to_50*1.0/target_time*100, time_to_75*1.0/target_time*100,
            time_to_87*1.0/target_time*100, time_to_100*1.0/target_time*100]
How long for 50,75,87.5, and 100% of tests to complete (as a percentage of target_time
recipes/Python/280030_Optimising_RegressiTesting_COmpute/recipe-280030.py