[Piglit] [PATCH] framework: make the interpret_result method for native tests faster

Dylan Baker dylan at pnwbakers.com
Thu Jun 2 19:00:45 UTC 2016


This reimplements the interpret_result method of PiglitBaseTest (which
is used by all native piglit tests) to loop once rather than twice.
There is a speedup of about 3 seconds for 10,000 iterations. Being that
piglit runs about 30,000 tests that is something, for a pretty
reasonable patch.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/test/piglit_test.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index 32a991b..ddef66b 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -25,9 +25,10 @@
 from __future__ import (
     absolute_import, division, print_function, unicode_literals
 )
+import glob
+import itertools
 import os
 import sys
-import glob
 try:
     import simplejson as json
 except ImportError:
@@ -68,14 +69,15 @@ class PiglitBaseTest(ValgrindMixin, Test):
         self._command[0] = os.path.join(TEST_BIN_DIR, self._command[0])
 
     def interpret_result(self):
-        outlines = self.result.out.split('\n')
-        outpiglit = (s[7:] for s in outlines if s.startswith('PIGLIT:'))
-
-        # FIXME: handle this properly. It needs a method in TestResult probably
-        for piglit in outpiglit:
-            self.result.update(json.loads(piglit))
-        self.result.out = '\n'.join(
-            s for s in outlines if not s.startswith('PIGLIT:'))
+        out = []
+
+        for each in self.result.out.split('\n'):
+            if each.startswith('PIGLIT:'):
+                self.result.update(json.loads(each[8:]))
+            else:
+                out.append(each)
+
+        self.result.out = '\n'.join(out)
 
         super(PiglitBaseTest, self).interpret_result()
 
-- 
2.8.3



More information about the Piglit mailing list