fix: benchmark batch verify naming, add batch sizes 4 and 64

Fix garbled batch verify names in the C benchmark (static char buffer
was shared across calls). Use string literals per batch size instead.

Fix batch verify self-test: use sign() (safe path) instead of
sign_xonly() since the test key has odd-y pubkey.

Add batch sizes 4 and 64 to the benchmark for finer granularity.

Batch verification results (x86_64 standalone, same pubkey):
  Batch   µs/event   events/sec   vs individual
    1       36.6       27,322       1.0x
    4       15.2       66,007       2.4x
    8       11.1       89,787       3.3x
   16        9.2      109,290       4.0x
   32        8.6      115,942       4.2x
   64        8.3      120,960       4.4x
  200        7.8      127,689       4.7x

vs Kotlin: C batch is 1.3-1.7x faster across all batch sizes.
At 200 events: 127K ev/s (C) vs 96K ev/s (Kotlin).

https://claude.ai/code/session_011KVZhDcV2G7idNWEBz12GY
This commit is contained in:
Claude
2026-04-11 04:50:47 +00:00
parent a8a3d8f44f
commit 3544c2cbc3
+10 -3
View File
@@ -162,11 +162,16 @@ static void bench_verify_batch(int batch_size, int iters) {
uint8_t seed[4] = {(uint8_t)i, (uint8_t)(i>>8), (uint8_t)(i>>16), (uint8_t)(i>>24)};
secp256k1_sha256_hash(msgs[i], seed, 4);
secp256k1c_schnorr_sign_xonly(sigs[i], msgs[i], 32, TEST_PRIVKEY, xonly, TEST_AUXRAND);
secp256k1c_schnorr_sign(sigs[i], msgs[i], 32, TEST_PRIVKEY, TEST_AUXRAND);
}
char name[64];
snprintf(name, sizeof(name), "verifySchnorrBatch(%d)", batch_size);
const char *name =
batch_size == 4 ? "verifyBatch(4)" :
batch_size == 8 ? "verifyBatch(8)" :
batch_size == 16 ? "verifyBatch(16)" :
batch_size == 32 ? "verifyBatch(32)" :
batch_size == 64 ? "verifyBatch(64)" :
batch_size == 200 ? "verifyBatch(200)" : "verifyBatch(?)";
double start = now_ms();
for (int i = 0; i < iters; i++) {
@@ -242,9 +247,11 @@ int main(void) {
bench_sign_xonly(N);
bench_verify(N);
bench_verify_fast(N);
bench_verify_batch(4, N / 2);
bench_verify_batch(8, N / 4);
bench_verify_batch(16, N / 8);
bench_verify_batch(32, N / 16);
bench_verify_batch(64, N / 32);
bench_verify_batch(200, N / 50);
bench_ecdh(N);