import timeit


def measure_overhead(timer_factory):
    """Measure the overhead of a timer instance from the given factory.

    :param timer_factory: callable which returns a new timer instance
    :return: the average duration of one observation, in seconds
    """
    timeit_timer = timeit.Timer(
        globals={'timer': timer_factory('foo', log_fn=lambda x: x)},
        stmt='with timer: pass'
    )
    n, duration = timeit_timer.autorange()
    min_duration = min([duration] + timeit_timer.repeat(number=n))
    return min_duration / n