Assume you are given clock, a function of no arguments that returns the current reading of some clock as a float - time.perf_counter is one such function, the ordinary time.time is another - and a positive integer max_reads.
Write clock_tick(clock, max_reads), which measures the smallest step the clock can show. Take a first reading; then keep reading the clock until a reading differs from that first one, and return how far the clock moved - the new reading minus the first. Stop reading the moment the clock moves.
The clock may be read at most max_reads times in all, the first reading included. If every one of those readings came back the same, the clock never moved within the budget: return 0.0.
A clock that sits at 2.0 for three readings and then jumps to 2.5 has a tick of half a second:
readings = [2.0, 2.0, 2.0, 2.5, 3.0] def fake_clock(): return readings.pop(0) print(clock_tick(fake_clock, 10)) # 0.5 print(clock_tick(time.perf_counter, 1000000) > 0) # True
Try it on both time.time and time.perf_counter and compare the two ticks.