Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add moving average stats #789

Merged
merged 18 commits into from
Mar 6, 2017
Merged

Conversation

lodoyun
Copy link
Contributor

@lodoyun lodoyun commented Mar 6, 2017

Description
Added two new types of stats:

  • MovingAverageStat: A moving average stat that can provide both the total average or a partial one from the last n samples

-MovingIntervalRateStat: A new RateStat that can be configured with an interval size and the number of intervals to track. It can also calculate the rate for the whole window or a partial rate from the last n ms

Add a short description here, please.

[X] It needs and includes Unit Tests

Changes in Client or Server public APIs
None.

Add a detailed description of any change in the public APIs.

[] It includes documentation for these changes in /doc.

Copy link
Contributor

@jcague jcague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! great rate stats coming to Licode!!


// if now is in the middle of an interval
// add the proportional part of the current interval
double interval_part = static_cast<double>((now_ms - (calculation_start_ms_ +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider calculating interval_part in another method, something like getCurrentIntervalProportion(now_ms);

}
int32_t intervals_to_pass = ((now_ms - real_interval) -
(calculation_start_ms_ + available_window * interval_size_ms_) * interval_size_ms_) / interval_size_ms_;
intervals_to_pass = intervals_to_pass < 0 ? 0 : intervals_to_pass; // can be less than zero in first value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider intervals_to_pass = std::max(intervals_to_pass, 0);

}

uint64_t now_ms = ClockUtils::timePointToMs(clock_->now());
// We check if it's within the data we have
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer moving logic to other self-explained methods vs adding comments

uint64_t now_ms = ClockUtils::timePointToMs(clock_->now());
// We check if it's within the data we have
uint32_t available_window = std::min(accumulated_intervals_, static_cast<uint64_t>(intervals_in_window_));
uint64_t min_requested_ms = std::max((now_ms - interval_to_calculate_ms),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider removing some parentheses:

uint64_t min_requested_ms = std::max(now_ms - interval_to_calculate_ms,
                                     calculation_start_ms_ + (accumulated_intervals_ - available_window) * interval_size_ms_);

@lodoyun lodoyun changed the title Add/moving average stats Add moving average stats Mar 6, 2017
@lodoyun lodoyun merged commit e41532e into lynckia:master Mar 6, 2017
@lodoyun lodoyun deleted the add/MovingAverageStats branch March 8, 2017 08:36
Arri98 pushed a commit to Arri98/licode that referenced this pull request Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants