It might make sense to split this benchmark into “labeled” and “unlabeled” variants in order to also get a feeling how overhead the labels scanning causes, with something like e.g.:
0diff --git a/src/modules/silentpayments/bench_impl.h b/src/modules/silentpayments/bench_impl.h
1index 1dd1e5a..366d172 100644
2--- a/src/modules/silentpayments/bench_impl.h
3+++ b/src/modules/silentpayments/bench_impl.h
4@@ -108,7 +108,7 @@ static void bench_silentpayments_output_scan(void* arg, int iters) {
5 }
6 }
7
8-static void bench_silentpayments_full_tx_scan(void* arg, int iters) {
9+static void bench_silentpayments_full_tx_scan(void* arg, int iters, int use_labels) {
10 int i;
11 size_t n_found = 0;
12 secp256k1_silentpayments_found_output *found_output_ptrs[2];
13@@ -116,6 +116,8 @@ static void bench_silentpayments_full_tx_scan(void* arg, int iters) {
14 const secp256k1_xonly_pubkey *tx_input_ptrs[2];
15 bench_silentpayments_data *data = (bench_silentpayments_data*)arg;
16 secp256k1_silentpayments_recipient_public_data public_data;
17+ const secp256k1_silentpayments_label_lookup label_lookup_fn = use_labels ? label_lookup : NULL;
18+ const void *label_context = use_labels ? label_cache : NULL;
19
20 for (i = 0; i < 2; i++) {
21 found_output_ptrs[i] = &data->found_outputs[i];
22@@ -135,11 +137,19 @@ static void bench_silentpayments_full_tx_scan(void* arg, int iters) {
23 data->scan_key,
24 &public_data,
25 &data->spend_pubkey,
26- label_lookup, label_cache)
27+ label_lookup_fn, label_context)
28 );
29 }
30 }
31
32+static void bench_silentpayments_full_tx_scan_unlabeled(void *arg, int iters) {
33+ bench_silentpayments_full_tx_scan(arg, iters, 0);
34+}
35+
36+static void bench_silentpayments_full_tx_scan_labeled(void *arg, int iters) {
37+ bench_silentpayments_full_tx_scan(arg, iters, 1);
38+}
39+
40 static void run_silentpayments_bench(int iters, int argc, char** argv) {
41 bench_silentpayments_data data;
42 int d = argc == 1;
43@@ -147,7 +157,8 @@ static void run_silentpayments_bench(int iters, int argc, char** argv) {
44 /* create a context with no capabilities */
45 data.ctx = secp256k1_context_create(SECP256K1_FLAGS_TYPE_CONTEXT);
46
47- if (d || have_flag(argc, argv, "silentpayments")) run_benchmark("silentpayments_full_tx_scan", bench_silentpayments_full_tx_scan, bench_silentpayments_scan_setup, NULL, &data, 10, iters);
48+ if (d || have_flag(argc, argv, "silentpayments")) run_benchmark("silentpayments_full_tx_scan_labeled", bench_silentpayments_full_tx_scan_labeled, bench_silentpayments_scan_setup, NULL, &data, 10, iters);
49+ if (d || have_flag(argc, argv, "silentpayments")) run_benchmark("silentpayments_full_tx_scan_unlabeled", bench_silentpayments_full_tx_scan_unlabeled, bench_silentpayments_scan_setup, NULL, &data, 10, iters);
50 if (d || have_flag(argc, argv, "silentpayments")) run_benchmark("silentpayments_output_scan", bench_silentpayments_output_scan, bench_silentpayments_scan_setup, NULL, &data, 10, iters);
51
52 secp256k1_context_destroy(data.ctx);
0Benchmark , Min(us) , Avg(us) , Max(us)
1
2silentpayments_full_tx_scan_labeled, 94.6 , 96.6 , 101.0
3silentpayments_full_tx_scan_unlabeled, 82.7 , 84.2 , 85.9
4silentpayments_output_scan , 85.3 , 87.5 , 90.7