def sumIO(io_list, pos, end_time):
  """
  Given io_list = [(timestamp, byte_count), ...], sorted by timestamp
  pos is an index in io_list
  end_time is either a timestamp or None

  Find end_index, where io_list[end_index] is the index of the first entry in
  io_list such that timestamp > end_time.
  Sum the byte_count values in io_list from [pos..end_index).
  Return (sum_byte_count, end_index).
  """
  sum_byte_count = 0
  # print(f'sum to {end_time}')
  while pos < len(io_list) and io_list[pos][0] <= end_time:
    # print(f'  {pos}')
    sum_byte_count += io_list[pos][1]
    pos += 1

  return (sum_byte_count, pos)