from typing import Coroutine
import time


async def coro_timed(coro: Coroutine, timing: dict):
    """Capture timing for a coroutine."""
    timing["started"] = time.perf_counter()
    try:
        return await coro
    finally:
        timing["ended"] = time.perf_counter()