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 <from...@redhat.com> Reviewed-on: https://gerrit.ovirt.org/53612 Continuous-Integration: Jenkins CI Reviewed-by: Dan Kenigsberg <dan...@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 <from...@redhat.com> Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches