[Piglit] [PATCH 1/2] status.py: convert status object attributes from instance to class
Dylan Baker
baker.dylan.c at gmail.com
Tue Oct 15 14:28:48 CEST 2013
This converts Status objects attributes to class attributes. This should
reduce lookup time and memory consumption of these classes.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/status.py | 51 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/framework/status.py b/framework/status.py
index 5267380..a265317 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -106,6 +106,9 @@ class Status(object):
# the memory consumed for creating tens of thousands of these objects.
__slots__ = ['name', 'value']
+ name = None
+ value = None
+
def __init__(self):
raise NotImplementedError
@@ -144,48 +147,64 @@ class Status(object):
class NotRun(Status):
+ name = 'Not Run'
+ value = 0
+
def __init__(self):
- self.name = 'Not Run'
- self.value = 0
+ pass
class Pass(Status):
+ name = 'pass'
+ value = 10
+
def __init__(self):
- self.name = 'pass'
- self.value = 10
+ pass
class DmesgWarn(Status):
+ name = 'dmesg-warn'
+ value = 20
+
def __init__(self):
- self.name = 'dmesg-warn'
- self.value = 20
+ pass
class Warn(Status):
+ name = 'warn'
+ value = 25
+
def __init__(self):
- self.name = 'warn'
- self.value = 25
+ pass
class DmesgFail(Status):
+ name = 'dmesg-fail'
+ value = 30
+
def __init__(self):
- self.name = 'dmesg-fail'
- self.value = 30
+ pass
class Fail(Status):
+ name = 'fail'
+ value = 35
+
def __init__(self):
- self.name = 'fail'
- self.value = 35
+ pass
class Crash(Status):
+ name = 'crash'
+ value = 40
+
def __init__(self):
- self.name = 'crash'
- self.value = 40
+ pass
class Skip(Status):
+ name = 'skip'
+ value = 50
+
def __init__(self):
- self.name = 'skip'
- self.value = 50
+ pass
--
1.8.1.5
More information about the Piglit
mailing list