From: zooko Date: Thu, 25 Jan 2007 23:50:26 +0000 (+0530) Subject: add dummy function to see how fast we can read in a file and invoke a Python function... X-Git-Url: https://git.rkrishnan.org/vdrive/components/%22news.html/configuration.txt?a=commitdiff_plain;h=cdacbf3d292004e8508a9162697ff7b9f908bca7;p=tahoe-lafs%2Fzfec.git add dummy function to see how fast we can read in a file and invoke a Python function on each segment darcs-hash:7d138467e7df11a8e237fc37627c8320ed50da27 --- diff --git a/pyfec/fec/filefec.py b/pyfec/fec/filefec.py index d18b69e..69b0101 100644 --- a/pyfec/fec/filefec.py +++ b/pyfec/fec/filefec.py @@ -105,6 +105,45 @@ def encode_file_stringy(inf, cb, k, m, chunksize=4096): # print "...finished to encode()" cb(res, indatasize) +def encode_file_not_really(inf, cb, k, m, chunksize=4096): + """ + Read in the contents of inf, and call cb with the results. + + @param inf the file object from which to read the data + @param cb the callback to be invoked with the results + @param k the number of shares required to reconstruct the file + @param m the total number of shares created + @param chunksize how much data to read from inf for each of the k input + shares + """ + enc = fec.Encoder(k, m) + l = tuple([ array.array('c') for i in range(k) ]) + indatasize = k*chunksize # will be reset to shorter upon EOF + ZEROES=array.array('c', ['\x00'])*chunksize + while indatasize == k*chunksize: + # This loop body executes once per segment. + i = 0 + while (i