Change in vdsm[ovirt-3.6]: vmstats: remove _diff helper
fromani at redhat.com
fromani at redhat.com
Wed Feb 24 15:28:12 UTC 2016
Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/54000
to review the following change.
Change subject: vmstats: remove _diff helper
......................................................................
vmstats: remove _diff helper
the _diff helper is pretty pointless: makes the code
harder to follow, not easier.
This patch drops it without changes in behaviour.
Change-Id: Ic0621d99b4d6a63ad68ed7374f4614b98a080a4e
Bug-Url: https://bugzilla.redhat.com/1299480
Backport-To: 3.6
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/53612
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/virt/vmstats.py
1 file changed, 5 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/54000/1
diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 5c3496f..49c51a8 100644
--- a/vdsm/virt/vmstats.py
+++ b/vdsm/virt/vmstats.py
@@ -113,14 +113,12 @@
stats['cpuUsage'] = str(last_sample['cpu.system'] +
last_sample['cpu.user'])
- stats['cpuSys'] = _usage_percentage(
- _diff(last_sample, first_sample, 'cpu.user') +
- _diff(last_sample, first_sample, 'cpu.system'),
- interval)
+ cpu_sys = ((last_sample['cpu.user'] - first_sample['cpu.user']) +
+ (last_sample['cpu.system'] - first_sample['cpu.system']))
+ stats['cpuSys'] = _usage_percentage(cpu_sys, interval)
+
stats['cpuUser'] = _usage_percentage(
- _diff(last_sample, first_sample, 'cpu.time')
- - _diff(last_sample, first_sample, 'cpu.user')
- - _diff(last_sample, first_sample, 'cpu.system'),
+ (last_sample['cpu.time'] - first_sample['cpu.time']) - cpu_sys,
interval)
except KeyError as e:
@@ -361,10 +359,6 @@
stats[name] = str(value)
return stats
-
-
-def _diff(prev, curr, val):
- return prev[val] - curr[val]
def _usage_percentage(val, interval):
--
To view, visit https://gerrit.ovirt.org/54000
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0621d99b4d6a63ad68ed7374f4614b98a080a4e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list