def test_performance_sequential(n, length): _str = random_string(length) _strarr = [_str for _ in range(n)] now = dt.now() [c.decompress(y) for y in [c.compressHC(x) for x in _strarr]] clz4_time = (dt.now() - now).total_seconds() now = dt.now() c.decompress_array(c.compressHC_array(_strarr)) clz4_time_p = (dt.now() - now).total_seconds() now = dt.now() [lz4_decompress(y) for y in [lz4_compress(x) for x in _strarr]] lz4_time = (dt.now() - now).total_seconds() print() print("LZ4 Test %sx len:%s" % (n, length)) print(" LZ4 HC %s s" % clz4_time) print(" LZ4 HC Parallel %s s" % clz4_time_p) print(" LZ4 %s s" % lz4_time)
def bench_multi(repeats, _strarr, use_HC, pool=None): measurements = [] for j in range(repeats): now = dt.now() if pool: # Raw LZ4 lib if use_HC: res = pool.map(c.lz4_compressHC, _strarr) else: res = pool.map(c.lz4_compress, _strarr) else: # Arctic's compression layer if use_HC: res = c.compressHC_array(_strarr) else: res = c.compress_array(_strarr, withHC=False) sample = (dt.now() - now).total_seconds() assert len(res) == len(_strarr) assert all(res) measurements.append(sample) return measurements
def test_arr_zero(): assert [] == c.compressHC_array([]) assert [] == c.decompress_array([])
def test_roundtrip_arrHC(n, length): _strarr = [random_string(length) for _ in range(n)] cstr = c.compressHC_array(_strarr) assert _strarr == c.decompress_array(cstr)