Skip to content

Commit ec4ce30

Browse files
committed
COBS/R overhead plot: Update to Python 3; tidy code
1 parent 00376fe commit ec4ce30

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

doc/pyplots/cobsr_overhead.py

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1+
#!/usr/bin/python3
12

23
from matplotlib import pyplot as plt
34
import numpy as np
45
from cobs import cobs
56
from cobs import cobsr
67

8+
# TODO: review value
9+
NUM_TESTS = 100000
710

811
def cobsr_overhead_calc(num_bytes):
912
return 257./256 - (255./256)**num_bytes
1013

1114
def cobsr_overhead_measure(num_bytes):
12-
# TODO: review value
13-
NUM_TESTS = 10000
1415
overhead = 0
15-
for _i in xrange(NUM_TESTS):
16+
for _i in range(NUM_TESTS):
1617
output = cobsr.encode(np.random.bytes(num_bytes))
1718
overhead += (len(output) - num_bytes)
1819
return overhead / float(NUM_TESTS)
1920

2021
def cobs_overhead_measure(num_bytes):
21-
# TODO: review value
22-
NUM_TESTS = 10000
2322
overhead = 0
24-
for _i in xrange(NUM_TESTS):
23+
for _i in range(NUM_TESTS):
2524
output = cobs.encode(np.random.bytes(num_bytes))
2625
overhead += (len(output) - num_bytes)
2726
return overhead / float(NUM_TESTS)
@@ -35,8 +34,9 @@ def cobs_overhead_measure(num_bytes):
3534
# Calculate values and plot
3635

3736
# Measured values for COBS
38-
#cobs_measured_overhead = [ cobs_overhead_measure(num_bytes) for num_bytes in num_bytes_list ]
39-
#ax1.plot(num_bytes_list, cobs_measured_overhead, 'g.')
37+
if 0:
38+
cobs_measured_overhead = [ cobs_overhead_measure(num_bytes) for num_bytes in num_bytes_list ]
39+
ax1.plot(num_bytes_list, cobs_measured_overhead, 'g.')
4040

4141
# Measured values for COBS/R
4242
cobsr_measured_overhead = [ cobsr_overhead_measure(num_bytes) for num_bytes in num_bytes_list ]

0 commit comments

Comments
 (0)