Change in vdsm[master]: vmstats: remove _diff helper
fromani at redhat.com
fromani at redhat.com
Tue Feb 16 18:05:26 UTC 2016
Francesco Romani has uploaded a new change for review.
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>
---
M vdsm/virt/vmstats.py
1 file changed, 5 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/53612/1
diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 7855b4b..447d5e6 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:
@@ -362,10 +360,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/53612
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0621d99b4d6a63ad68ed7374f4614b98a080a4e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
More information about the vdsm-patches
mailing list