Skip to content

Commit

Permalink
benchmark with settable buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Mar 23, 2024
1 parent bc52249 commit 9a0160a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions spf/sdrpluto/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tqdm import tqdm


def get_sdr(uri, rx_buffer_size=2 * 16):
def get_sdr(uri, rx_buffer_size=2 * 16, rx_buffers=None):
sdr = adi.ad9361(uri=uri)
# Create radio
# Configure properties
Expand All @@ -18,11 +18,14 @@ def get_sdr(uri, rx_buffer_size=2 * 16):
sdr.gain_control_mode_chan0 = "fast_attack"
sdr.gain_control_mode_chan1 = "fast_attack"
sdr.tx_enabled_channels = [0]
if rx_buffers is not None:
sdr._rxadc.set_kernel_buffers_count(rx_buffers)

return sdr


def benchmark(uri, rx_buffer_size, total_samples=2**24):
sdr = get_sdr(uri, rx_buffer_size=rx_buffer_size)
def benchmark(uri, rx_buffer_size, total_samples=2**24, rx_buffers=None):
sdr = get_sdr(uri, rx_buffer_size=rx_buffer_size, rx_buffers=rx_buffers)
assert total_samples % rx_buffer_size == 0
assert sdr.rx()[0].shape[0] == rx_buffer_size
start_time = time.time()
Expand All @@ -49,11 +52,22 @@ def benchmark(uri, rx_buffer_size, total_samples=2**24):
)
parser.add_argument(
"--buffer-size",
type=str,
help="buffer size (can use 2**X)",
required=True,
)
parser.add_argument(
"--rx-buffers",
type=int,
help="buffer size",
help="how many rx buffers",
required=True,
)
args = parser.parse_args()

if "2**" in args.buffer_size:
args.buffer_size = 2 ** (int(args.buffer_size.split("**")[1]))
else:
args.buffer_size = int(args.buffer_size)

for k, v in benchmark(args.uri, args.buffer_size).items():
print(f"{k}: {v}")

0 comments on commit 9a0160a

Please sign in to comment.