runtime
363 / 500
question 363 Profiling & Optimization · easy

Summarise a benchmark run

A CI job stores the totals that timeit.repeat returned. Write summarise(totals, number) for its report: the best and worst per-call times and how noisy the run was (the worst round divided by the best).

Functionsummarise(totals, number)
totalsa non-empty list of round totals in seconds, each for number calls
Returns{"best": …, "worst": …, "spread": …}: best and worst per-call seconds, and worst total ÷ best total
Examples
callsummarise([0.41, 0.4, 0.52], 1000)returns{'best': 0.0004, 'worst': 0.00052, 'spread': 1.3}
callsummarise([2, 1], 10)returns{'best': 0.1, 'worst': 0.2, 'spread': 2.0}
callsummarise([0.5], 5)returns{'best': 0.1, 'worst': 0.1, 'spread': 1.0}

Loading your progress…

Summarise a benchmark run — Python practice · Runtime