Skip to content

Commit

Permalink
Merge bitcoin-core/secp256k1#1301: Avoid using bench_verify_data as b…
Browse files Browse the repository at this point in the history
…ench_sign_data; merge them

2e65f1f Avoid using bench_verify_data as bench_sign_data; merge them (Pieter Wuille)

Pull request description:

  The existing bench.c code defines `bench_verify_data data` variable, but some of the benchmarks then use it as `bench_sign`. Fix this by merging the two types into one.

ACKs for top commit:
  stratospher:
    ACK 2e65f1f.
  real-or-random:
    utACK bitcoin-core/secp256k1@2e65f1f

Tree-SHA512: 676b43e5d30abd13bfd9595378b1a0bd90a2e713be4f8f713260f989ea8c971b229dfb683cd7a1614665b1688a0bdda7a4019f358dd6cd645e1b3d9f8d71e814
  • Loading branch information
real-or-random committed May 10, 2023
2 parents 1cf15eb + 2e65f1f commit 24c768a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ typedef struct {
size_t siglen;
unsigned char pubkey[33];
size_t pubkeylen;
} bench_verify_data;
} bench_data;

static void bench_verify(void* arg, int iters) {
int i;
bench_verify_data* data = (bench_verify_data*)arg;
bench_data* data = (bench_data*)arg;

for (i = 0; i < iters; i++) {
secp256k1_pubkey pubkey;
Expand All @@ -85,15 +85,9 @@ static void bench_verify(void* arg, int iters) {
}
}

typedef struct {
secp256k1_context* ctx;
unsigned char msg[32];
unsigned char key[32];
} bench_sign_data;

static void bench_sign_setup(void* arg) {
int i;
bench_sign_data *data = (bench_sign_data*)arg;
bench_data *data = (bench_data*)arg;

for (i = 0; i < 32; i++) {
data->msg[i] = i + 1;
Expand All @@ -105,7 +99,7 @@ static void bench_sign_setup(void* arg) {

static void bench_sign_run(void* arg, int iters) {
int i;
bench_sign_data *data = (bench_sign_data*)arg;
bench_data *data = (bench_data*)arg;

unsigned char sig[74];
for (i = 0; i < iters; i++) {
Expand Down Expand Up @@ -137,7 +131,7 @@ int main(int argc, char** argv) {
int i;
secp256k1_pubkey pubkey;
secp256k1_ecdsa_signature sig;
bench_verify_data data;
bench_data data;

int d = argc == 1;
int default_iters = 20000;
Expand Down

0 comments on commit 24c768a

Please sign in to comment.