From: zooko Date: Sun, 6 Mar 2011 06:12:48 +0000 (+0530) Subject: bench: add note to README.rst about how to run the benchmarks, update the "not really... X-Git-Url: https://git.rkrishnan.org/listings/%3C?a=commitdiff_plain;h=344e30bdaa0dc4f8e75c624672f6d284c8831bb1;p=tahoe-lafs%2Fzfec.git bench: add note to README.rst about how to run the benchmarks, update the "not really encoding" dummy function in the benchmarks Ignore-this: 3517ed007d89f3f90d817274d520e9a3 darcs-hash:7be6784eb847aa3defdf0ef9d62befc43ff014e3 --- diff --git a/zfec/README.rst b/zfec/README.rst index e09d8f3..0ee8ede 100644 --- a/zfec/README.rst +++ b/zfec/README.rst @@ -146,6 +146,9 @@ proof-of-retrievability, and repair of damaged files and directories. 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 diff --git a/zfec/bench/bench_zfec.py b/zfec/bench/bench_zfec.py index 93cb625..9a9b8e2 100644 --- a/zfec/bench/bench_zfec.py +++ b/zfec/bench/bench_zfec.py @@ -21,7 +21,9 @@ ds = [] 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) @@ -57,11 +59,15 @@ def _encode_file_and_hash(N): 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) @@ -77,7 +83,8 @@ def bench(k, m): # 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]: