From 98f3eb75c05a234cae0300fe33d7edb9d2229d50 Mon Sep 17 00:00:00 2001 From: noah Date: Fri, 16 Oct 2026 14:04:32 -0600 Subject: [PATCH] Benchmark BM13xx protocol checksums --- ci/metrics.py | 1 + tests/bench.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ci/metrics.py b/ci/metrics.py index 2cd09d4..e409574 100644 --- a/ci/metrics.py +++ b/ci/metrics.py @@ -20,6 +20,7 @@ EXPECTED_BENCHES = frozenset({ "stratum_configure_format", "stratum_subscribe_format", "stratum_subscription_parse", "stratum_accept_parse", "hal_socket_exchange", "stratum_socket_round_trip", + "bm13xx_crc5", "bm13xx_crc16", }) BENCH_LINE = re.compile(r"\bBENCH ([A-Za-z0-9_]+) ([0-9]+(?:\.[0-9]+)?) ns/op\Z") diff --git a/tests/bench.rs b/tests/bench.rs index 65298e0..cc944e4 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -3,6 +3,7 @@ use alkane_os::bm1362::{ read_register_all, set_chip_address, write_register, write_register_all, Job, S19J_PRO, }; use alkane_os::bm1366::{decode_nonce_report, encode_work}; +use alkane_os::bm13xx::{crc16, crc5}; use alkane_os::difficulty::PoolDifficulty; use alkane_os::hal_wire::HalClient; use alkane_os::miner::Bm1366Miner; @@ -72,6 +73,24 @@ fn bench_power_policy() { }); } +#[test] +#[ignore = "microbenchmark"] +fn bench_bm13xx_crc5() { + let command = [0x53, 0x05, 0, 0]; + measure("bm13xx_crc5", 100_000, || { + black_box(crc5(black_box(&command))); + }); +} + +#[test] +#[ignore = "microbenchmark"] +fn bench_bm13xx_crc16() { + let job = [0x21_u8; 84]; + measure("bm13xx_crc16", 20_000, || { + black_box(crc16(black_box(&job))); + }); +} + #[test] #[ignore = "microbenchmark"] fn bench_share_verification() {