Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixes for python 3 compatibility #82

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions bench/bench_zfec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def _make_new_rand_data(size, k, m):
blocksize = mathutil.div_ceil(size, k)
for i in range(k):
ds[i] = d[i*blocksize:(i+1)*blocksize]
ds[-1] = ds[-1] + "\x00" * (len(ds[-2]) - len(ds[-1]))
ds[-1] = ds[-1] + b"\x00" * (len(ds[-2]) - len(ds[-1]))
easyfecenc = easyfec.Encoder(k, m)
fecenc = Encoder(k, m)

import sha
hashers = [ sha.new() for i in range(M) ]
from hashlib import sha1 as sha
hashers = [ sha() for i in range(M) ]
def hashem(results, reslenthing):
for i, result in enumerate(results):
hashers[i].update(result)
Expand Down Expand Up @@ -82,21 +82,21 @@ def bench(k, m):
# for f in [_encode_file,]:
# 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)
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, _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]:
results = benchutil.rep_bench(f, n=BSIZE, initfunc=_init_func, MAXREPS=MAXREPS, MAXTIME=None, UNITS_PER_SECOND=1000000000)
print "and now represented in MB/s..."
print
results = benchutil.rep_bench(f, n=BSIZE, initfunc=_init_func, runreps=MAXREPS, UNITS_PER_SECOND=1000000000)
print("and now represented in MB/s...")
print()
best = results['best']
mean = results['mean']
worst = results['worst']
print "best: % 4.3f MB/sec" % (10**3 / best)
print "mean: % 4.3f MB/sec" % (10**3 / mean)
print "worst: % 4.3f MB/sec" % (10**3 / worst)
print("best: % 4.3f MB/sec" % (10**3 / best))
print("mean: % 4.3f MB/sec" % (10**3 / mean))
print("worst: % 4.3f MB/sec" % (10**3 / worst))

k = K
m = M
Expand Down