| To: | pcp developers <pcp@xxxxxxxxxxx> |
|---|---|
| Subject: | pmrep: simplify rescale code |
| From: | Marko Myllynen <myllynen@xxxxxxxxxx> |
| Date: | Mon, 18 Jan 2016 11:26:58 +0200 |
| Delivered-to: | pcp@xxxxxxxxxxx |
| Organization: | Red Hat |
| Reply-to: | Marko Myllynen <myllynen@xxxxxxxxxx> |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
Hopefully simplify and make the code easier to read.
No functional change (see also validate_metrics()).
---
src/pmrep/pmrep.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index b64c1d6..c7b5ea5 100644
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -902,9 +902,11 @@ class PMReporter(object):
# Extract and scale the value
try:
# Use native type if no rescaling needed
- if self.metrics[metric][2][2] == 1 and \
- str(self.descs[i].contents.units) == \
- str(self.metrics[metric][2][1]):
+ if self.descs[i].contents.type == PM_TYPE_STRING or \
+ self.metrics[metric][3] == 1 or \
+ (self.metrics[metric][2][2] == 1 and \
+ str(self.descs[i].contents.units) == \
+ str(self.metrics[metric][2][1])):
rescale = 0
vtype = self.descs[i].contents.type
else:
@@ -917,16 +919,15 @@ class PMReporter(object):
self.descs[i].contents.type,
vtype)
- if self.metrics[metric][3] != 1 and rescale and \
- self.descs[i].contents.type != PM_TYPE_STRING:
+ if rescale:
atom = self.context.pmConvScale(
vtype,
atom, self.descs, i,
self.metrics[metric][2][1])
val = atom.dref(vtype)
- if rescale and \
- self.descs[i].contents.type != PM_TYPE_STRING:
+
+ if rescale:
val *= self.metrics[metric][2][2]
val = int(val) if val == int(val) else val
Thanks,
--
Marko Myllynen
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | pmrep: drop RHBZ#1285371 compat code, Marko Myllynen |
|---|---|
| Next by Date: | pmrep: fix reporting of the first sample, Marko Myllynen |
| Previous by Thread: | pmrep: drop RHBZ#1285371 compat code, Marko Myllynen |
| Next by Thread: | pmrep: fix reporting of the first sample, Marko Myllynen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |