def METHOD_NAME(self, config, now):
    # purge old samples before we compute the window size
    self._stat.purge_obsolete_samples(config, now)
    """
    Here we check the total amount of time elapsed since the oldest
    non-obsolete window. This give the total window_size of the batch
    which is the time used for Rate computation. However, there is
    an issue if we do not have sufficient data for e.g. if only
    1 second has elapsed in a 30 second window, the measured rate
    will be very high. Hence we assume that the elapsed time is
    always N-1 complete windows plus whatever fraction of the final
    window is complete.
    Note that we could simply count the amount of time elapsed in
    the current window and add n-1 windows to get the total time,
    but this approach does not account for sleeps. AbstractSampledStat
    only creates samples whenever record is called, if no record is
    called for a period of time that time is not accounted for in
    window_size and produces incorrect results.
    """
    total_elapsed_time_ms = now - self._stat.oldest(now).last_window_ms
    # Check how many full windows of data we have currently retained
    num_full_windows = int(total_elapsed_time_ms / config.time_window_ms)
    min_full_windows = config.samples - 1
    # If the available windows are less than the minimum required,
    # add the difference to the totalElapsedTime
    if num_full_windows < min_full_windows:
        total_elapsed_time_ms += ((min_full_windows - num_full_windows) *
                                  config.time_window_ms)
    return total_elapsed_time_ms