def log_iter_durations(seq, print_func, label=None, unit='auto'):
    """Times processing of each item in seq."""
    if unit not in time_formatters:
        raise ValueError('Unknown time unit: %s. It should be ns, mks, ms, s or auto.' % unit)
    _format_time = time_formatters[unit]
    suffix = " of %s" % label if label else ""
    it = iter(seq)
    for i, item in enumerate(it):
        start = timer()
        yield item
        duration = _format_time(timer() - start)
        print_func("%s in iteration %d%s" % (duration, i, suffix))
Times processing of each item in seq.
funcy/debug.py