def _iou(p1, p2):
    """Computes intersection over union of two intervals.
    Args:
        p1 ((int,int)): First interval as (first ts, last ts)
        p2 ((int,int)): Second interval as (first ts, last ts)
        
    Returns:
        float: intersection over union of the two intervals.
    """
    i_start = max(p1[0],p2[0])
    i_end = min(p1[1],p2[1])
    i_len = max(0,i_end-i_start)
    o_start = min(p1[0],p2[0])
    o_end = max(p1[1],p2[1])
    o_len = o_end-o_start
    return float(i_len)/o_len