[SCB-1096]change the method calculate process cpu rate to same with top#1047
Merged
liubao68 merged 4 commits intoapache:masterfrom Jan 14, 2019
heyile:htopMetrix
Merged
[SCB-1096]change the method calculate process cpu rate to same with top#1047liubao68 merged 4 commits intoapache:masterfrom heyile:htopMetrix
liubao68 merged 4 commits intoapache:masterfrom
heyile:htopMetrix
Conversation
liubao68
reviewed
Jan 4, 2019
|
|
||
| public void update() { | ||
| String[] stats; | ||
| @SuppressWarnings("deprecation") |
Contributor
There was a problem hiding this comment.
Do not use deprecated method, we can write a new one if no other available
…op: fix as reviewed
wujimin
reviewed
Jan 11, 2019
| long currentIdle = Long.parseLong(stats[4]); | ||
| idle.update(currentIdle); | ||
|
|
||
| long totalCpu = 0L; |
Contributor
There was a problem hiding this comment.
1.delete useless empty lines.
2.why not just invoke CpuUtils.summary?
String[] stats = CpuUtils.readAndSplitFirstLine(PROC_STAT);
total.update(CpuUtils.summary(stats, 1, 8));
idle.update(Double.parseDouble(stats[4]));
super.updateUsage(total.period - idle.period, total.period, false);
|
|
||
| public long getLastTotalTime() { | ||
| return lastTotalTime; | ||
| protected void updateUsage(double periodBusy, double periodTotal) { |
Contributor
There was a problem hiding this comment.
move to parent class
protected void updateUsage(double periodBusy, double periodTotal, boolean irixMode) {
usage = periodTotal == 0 ? 0 : periodBusy / periodTotal;
if (usage > 1) {
usage = 1;
}
if (irixMode) {
usage *= cpuCount;
}
}
| long busy = 0L; | ||
| for (int i = 13; i <= 16; i++) { | ||
| busy += Long.parseLong(stats[i]); | ||
| protected void updateUsage(double periodBusy, double periodTotal) { |
| return name.substring(0, idx); | ||
| public void update() { | ||
| String[] stats = CpuUtils.readAndSplitFirstLine(CpuUtils.SELF_PROCESS); | ||
| String[] uptime = CpuUtils.readAndSplitFirstLine(CpuUtils.UPTIME); |
Contributor
There was a problem hiding this comment.
why not just invoke readUptimeTotal?
| appendLine(sb, " cpu:"); | ||
| appendLine(sb, " all: %.2f%% process: %.2f%%", allRate * 100, processRate * 100); | ||
| appendLine(sb, " all: %.2f%% process: %.2f%% idle: %.2f%%", allRate * 100, processRate * 100, | ||
| (1 - allRate) * 100); |
Contributor
There was a problem hiding this comment.
appendLine(sb, " all usage: %.2f%% all idle: %.2%% process: %.2f%%", allRate * 100, (1 - allRate) * 100, processRate * 100);
…op: fix as reviewed
…op: reconstruct exception
wujimin
approved these changes
Jan 14, 2019
liubao68
approved these changes
Jan 14, 2019
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles, where you replaceSCB-XXXwith the appropriate JIRA issue.mvn clean installto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.