This adds support to compress results with gzip compression. This
reduces the size of json results significantly (from 21M to 1.6M when
running the quick profile (which is about 7% of the uncompressed size).

Signed-off-by: Dylan Baker <[email protected]>
---
 framework/backends/compression.py           |  9 ++++++---
 framework/tests/compressed_backend_tests.py | 11 +++++++++++
 piglit.conf.example                         |  6 +++---
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/framework/backends/compression.py 
b/framework/backends/compression.py
index e9c90ea..1bda991 100644
--- a/framework/backends/compression.py
+++ b/framework/backends/compression.py
@@ -43,21 +43,24 @@ they're passing unicode and not bytes.
 
 from __future__ import print_function, absolute_import, division
 import functools
+import gzip
 import os
 
 from framework import exceptions
 from framework.core import PIGLIT_CONFIG
 
-COMPRESSION_SUFFIXES = []
+COMPRESSION_SUFFIXES = ['.gz']
 
-DEFAULT = 'none'
+DEFAULT = 'gz'
 
 COMPRESSORS = {
+    'gz': functools.partial(gzip.open, mode='w'),
     'none': functools.partial(open, mode='w'),
 }
 
 DECOMPRESSORS = {
-    'none': functools.partial(open, mode='r')
+    'gz': functools.partial(gzip.open, mode='r'),
+    'none': functools.partial(open, mode='r'),
 }
 
 
diff --git a/framework/tests/compressed_backend_tests.py 
b/framework/tests/compressed_backend_tests.py
index 44f8259..4a7db75 100644
--- a/framework/tests/compressed_backend_tests.py
+++ b/framework/tests/compressed_backend_tests.py
@@ -66,3 +66,14 @@ def test_compress_none():
 def test_decompress_none():
     """framework.backends.compression: can decompress from 'none'"""
     _test_decompressor('none')
+
+
[email protected]_error
+def test_compress_gz():
+    """framework.backends.compression: can compress to 'gz'"""
+    _test_compressor('gz')
+
+
+def test_decompress_gz():
+    """framework.backends.compression: can decompress from 'gz'"""
+    _test_decompressor('gz')
diff --git a/piglit.conf.example b/piglit.conf.example
index 49bc8b6..baf8108 100644
--- a/piglit.conf.example
+++ b/piglit.conf.example
@@ -111,9 +111,9 @@ run_test=./%(test_name)s
 ;backend=json
 
 ; Set the default compression method to use,
-; May be one of: 'none'
-; Default: none (Note that this may change in the future)
-;compression=none
+; May be one of: 'none', 'gz'
+; Default: 'gz'
+;compression=gz
 
 [expected-failures]
 ; Provide a list of test names that are expected to fail.  These tests
-- 
2.4.3

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to