Mercurial > public > mercurial-scm > hg
comparison contrib/python-zstandard/tests/common.py @ 31796:e0dc40530c5a
zstd: vendor python-zstandard 0.8.0
Commit 81e1f5bbf1fc54808649562d3ed829730765c540 from
https://github.com/indygreg/python-zstandard is imported without
modifications (other than removing unwanted files).
Updates relevant to Mercurial include:
* Support for multi-threaded compression (we can use this for
bundle and wire protocol compression).
* APIs for batch compression and decompression operations using
multiple threads and optimal memory allocation mechanism. (Can
be useful for revlog perf improvements.)
* A ``BufferWithSegments`` type that models a single memory buffer
containing N discrete items of known lengths. This type can be
used for very efficient 0-copy data operations.
# no-check-commit
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 01 Apr 2017 15:24:03 -0700 |
parents | c32454d69b85 |
children | b1fb341d8a61 |
comparison
equal
deleted
inserted
replaced
31795:2b130e26c3a4 | 31796:e0dc40530c5a |
---|---|
1 import inspect | 1 import inspect |
2 import io | 2 import io |
3 import os | |
3 import types | 4 import types |
4 | 5 |
5 | 6 |
6 def make_cffi(cls): | 7 def make_cffi(cls): |
7 """Decorator to add CFFI versions of each test method.""" | 8 """Decorator to add CFFI versions of each test method.""" |
57 return super(OpCountingBytesIO, self).read(*args) | 58 return super(OpCountingBytesIO, self).read(*args) |
58 | 59 |
59 def write(self, data): | 60 def write(self, data): |
60 self._write_count += 1 | 61 self._write_count += 1 |
61 return super(OpCountingBytesIO, self).write(data) | 62 return super(OpCountingBytesIO, self).write(data) |
63 | |
64 | |
65 _source_files = [] | |
66 | |
67 | |
68 def random_input_data(): | |
69 """Obtain the raw content of source files. | |
70 | |
71 This is used for generating "random" data to feed into fuzzing, since it is | |
72 faster than random content generation. | |
73 """ | |
74 if _source_files: | |
75 return _source_files | |
76 | |
77 for root, dirs, files in os.walk(os.path.dirname(__file__)): | |
78 dirs[:] = list(sorted(dirs)) | |
79 for f in sorted(files): | |
80 try: | |
81 with open(os.path.join(root, f), 'rb') as fh: | |
82 data = fh.read() | |
83 if data: | |
84 _source_files.append(data) | |
85 except OSError: | |
86 pass | |
87 | |
88 return _source_files |