def performance(agraph, monitor):
    """Add performance monitor information to a graph diagram.

    Parameters
    ----------
    agraph: :class:`pygraphviz.AGraph`, required
        Diagram originally created using :func:`draw`.
    monitor: :class:`graphcat.common.PerformanceMonitor`, required
        Performance monitor object containing performance results to be
        added to `agraph`

    Returns
    -------
    diagram: :class:`pygraphviz.AGraph`
        Input diagram supplemented with performance results from `monitor`.
    """
    all_times = [times[-1] for times in monitor.tasks.values()]
    min_time = min(all_times)
    max_time = max(all_times)

    agraph = agraph.copy()
    agraph.graph_attr["forcelabels"] = True
    for name, times in monitor.tasks.items():
        time = times[-1]
        if max_time - min_time > 0:
            percent = (time - min_time) / (max_time - min_time)
            if percent > 0.66:
                timecolor = "red"
            elif percent > 0.33:
                timecolor = "#ffaa00"
            else:
                timecolor = "green"
        else:
            timecolor="black"
        agraph.get_node(name).attr["xlabel"] = f"<<font color='{timecolor}'>&#11044;</font> <font color='black'>{time:.4f}s</font>>"
    return agraph