def binary_search(datafiles, timestamp):
    """Performs a binary search in the list of datafiles, for the index of the first data file that contain events that
    happened at or after the provided timestamp.

    :param datafiles: ``list`` of :class:`DataFile`, list of datafiles **sorted** in ascending order by the start
        timestamp.
    :param timestamp: ``float``, the timestamp to serch for.

    Returns the index (``int``) of the first :class:`DataFile` in the list that contains event that occurred at or
    after the provided timestamp. Returns ``None`` if no such data file can be found.
    """
    start = 0
    end = len(datafiles) - 1
    if not datafiles:
        return None
    if datafiles[0].start > timestamp or datafiles[-1].end < timestamp:
        return None
    while True:
        mid = (end + start) // 2
        if datafiles[mid].end >= timestamp:
            end = mid
        else:
            start = mid
        if end - start <= 1:
            if datafiles[start].end >= timestamp:
                return start
            return end
    return None
