return bloscpack.pretty_size(path.getsize(file_name)) def get_ratio(file1, file2): return path.getsize(file1)/path.getsize(file2) blosc_args = bloscpack.DEFAULT_BLOSC_ARGS with tb.create_tmp_files() as (tdir, in_file, out_file, dcmp_file): gz_out_file = path.join(tdir, 'file.gz') print('create the test data', end='') def progress(i): if i % 10 == 0: print('.', end='') sys.stdout.flush() tb.create_array(100, in_file, progress=progress) print('') print("Input file size: %s" % get_fs(in_file)) print("Will now run bloscpack... ") tic = time.time() bloscpack.pack_file(in_file, out_file, blosc_args, chunk_size=bloscpack.reverse_pretty(bloscpack.DEFAULT_CHUNK_SIZE)) toc = time.time() print("Time: %.2f seconds" % (toc - tic)) print("Output file size: %s" % get_fs(out_file)) print("Ratio: %.2f" % get_ratio(out_file, in_file)) print("Will now run gzip... ") tic = time.time()
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import division import os.path as path import time import numpy import bloscpack import test_bloscpack as tb blosc_args = bloscpack.DEFAULT_BLOSC_ARGS with tb.create_tmp_files() as (tdir, in_file, out_file, dcmp_file): tb.create_array(100, in_file) repeats = 3 print "%s\t\t%s\t\t%s\t\t%s" % ("chunk_size", "comp-time", "decomp-time", "ratio") for chunk_size in (int(2**i) for i in numpy.arange(19, 23.5, 0.5)): cmp_times, dcmp_times = [], [] for _ in range(repeats): tic = time.time() bloscpack.pack_file(in_file, out_file, blosc_args, chunk_size=chunk_size) toc = time.time() cmp_times.append(toc-tic) tic = time.time() bloscpack.unpack_file(out_file, dcmp_file) toc = time.time() dcmp_times.append(toc-tic) ratio = path.getsize(out_file)/path.getsize(in_file) print "%d\t\t%f\t\t%f\t\t%f" % (chunk_size, sum(cmp_times)/repeats,
DROP_CACHES = True else: print('error: need uid 0 (root) to drop caches') sys.exit(1) with tb.create_tmp_files() as (tdir, in_file, out_file, dcmp_file): gz_out_file = path.join(tdir, 'file.gz') print('create the test data', end='') def progress(i): if i % 10 == 0: print('.', end='') sys.stdout.flush() tb.create_array(100, in_file, progress=progress) print('') print("Input file size: %s" % get_fs(in_file)) drop_caches() print("Will now run bloscpack... ") tic = time.time() bloscpack.pack_file(in_file, out_file) toc = time.time() print("Time: %.2f seconds" % (toc - tic)) print("Output file size: %s" % get_fs(out_file)) print("Ratio: %.2f" % get_ratio(out_file, in_file)) drop_caches() print("Will now run gzip... ")
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import division import os.path as path import time import numpy import bloscpack import test_bloscpack as tb blosc_args = bloscpack.DEFAULT_BLOSC_ARGS with tb.create_tmp_files() as (tdir, in_file, out_file, dcmp_file): tb.create_array(100, in_file) repeats = 3 print "%s\t\t%s\t\t%s\t\t%s" % ("chunk_size", "comp-time", "decomp-time", "ratio") for chunk_size in (int(2**i) for i in numpy.arange(19, 23.5, 0.5)): cmp_times, dcmp_times = [], [] for _ in range(repeats): tic = time.time() bloscpack.pack_file(in_file, out_file, blosc_args, chunk_size=chunk_size) toc = time.time() cmp_times.append(toc - tic) tic = time.time() bloscpack.unpack_file(out_file, dcmp_file) toc = time.time()