Performance
-----------
+To run the benchmarks, execute the included bench/bench_zfec.py script
+with optional --k= and --m= arguments.
+
On my Athlon 64 2.4 GHz workstation (running Linux), the "zfec" command-line
tool encoded a 160 MB file with m=100, k=94 (about 6% redundancy) in 3.9
seconds, where the "par2" tool encoded the file with about 6% redundancy in 27
easyfecenc = None
fecenc = None
def _make_new_rand_data(size, k, m):
- global d, easyfecenc, fecenc
+ global d, easyfecenc, fecenc, K, M
+ K = k
+ M = m
d = os.urandom(size)
del ds[:]
ds.extend([None]*k)
filefec.encode_file(open(FNAME, "rb"), hashem, K, M)
def _encode_data_not_really(N):
- i = 0
- for c in d:
- i += 1
- assert len(d) == N == i
- pass
+ # This function is to see how long it takes to run the Python code
+ # that does this benchmarking and accounting and so on but not
+ # actually do any erasure-coding, in order to get an idea of how
+ # much overhead there is in using Python. This exercises the
+ # basic behavior of allocating buffers to hold the secondary
+ # shares.
+ sz = N // K
+ for i in range(M-K):
+ x = '\x00' * sz
def _encode_data_easyfec(N):
easyfecenc.encode(d)
# for f in [_encode_file_not_really, _encode_file_not_really_and_hash, _encode_file, _encode_file_and_hash,]:
# for f in [_encode_data_not_really, _encode_data_easyfec, _encode_data_fec,]:
print "measuring encoding of data with K=%d, M=%d, reporting results in nanoseconds per byte after encoding %d bytes %d times in a row..." % (k, m, SIZE, MAXREPS)
- for f in [_encode_data_fec,]:
+ # for f in [_encode_data_fec, _encode_data_not_really]:
+ for f in [_encode_data_fec]:
def _init_func(size):
return _make_new_rand_data(size, k, m)
for BSIZE in [SIZE]: