Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #40 from grossman/scheduler_usage_diff_divide_by_zero
Avoid divide by zero in scheduler_usage/1 on lightly loaded systems.
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-module(recon_lib_SUITE). | ||
-include_lib("common_test/include/ct.hrl"). | ||
-compile(export_all). | ||
|
||
all() -> [scheduler_usage_diff]. | ||
|
||
scheduler_usage_diff(_Config) -> | ||
{Active0, Total0} = {1000, 2000}, | ||
SchedStat0 = {1, Active0, Total0}, | ||
% No active or total time has elapsed. Make sure we don't divide by zero. | ||
[{1, 0.0}] = recon_lib:scheduler_usage_diff([SchedStat0], [SchedStat0]), | ||
% Total time has elapsed, but no active time. Make sure we get 0 usage back. | ||
SchedStat1 = {1, Active0, Total0 * 2}, | ||
[{1, 0.0}] = recon_lib:scheduler_usage_diff([SchedStat0], [SchedStat1]), | ||
% Check for 100% usage | ||
SchedStat2 = {1, Active0 + 1000, Total0 + 1000}, | ||
[{1, 1.0}] = recon_lib:scheduler_usage_diff([SchedStat0], [SchedStat2]). |