Bitcoin ABC 0.32.6
P2P Digital Currency
bench_impl.h
Go to the documentation of this file.
1/***********************************************************************
2 * Copyright (c) 2017 Tomas van der Wansem *
3 * Distributed under the MIT software license, see the accompanying *
4 * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5 ***********************************************************************/
6
7#ifndef SECP256K1_MODULE_MULTISET_BENCH_H
8#define SECP256K1_MODULE_MULTISET_BENCH_H
9
10#include "../../bench.h"
11#include "../include/secp256k1_multiset.h"
12
14
15#define UNUSED(x) (void)(x)
16
17#define BUFSIZE (3 * 32)
18
19void bench_multiset(void* arg, int iters) {
20 int it = 0;
21 int n, m;
22 unsigned char result[32];
23 secp256k1_multiset multiset;
24
25 UNUSED(arg);
26 secp256k1_multiset_init(ctx, &multiset);
27
28 for (m = 0; m < iters; m++) {
29 unsigned char buf[BUFSIZE];
30 for (n = 0; n < BUFSIZE; n++) {
31 buf[n] = it++;
32 }
33
34 secp256k1_multiset_add(ctx, &multiset, buf, sizeof(buf));
35 }
36
37 secp256k1_multiset_finalize(ctx, result, &multiset);
38}
39
40void bench_multiset_setup(void* arg) {
41 UNUSED(arg);
42}
43
44void run_multiset_bench(int iters, int argc, char** argv) {
45 int d = argc ==1;
47 if (d || have_flag(argc, argv, "multiset")) run_benchmark("multiset", bench_multiset, bench_multiset_setup, NULL, NULL, 5, iters);
49}
50
51#endif /* SECP256K1_MODULE_MULTISET_BENCH_H */
secp256k1_context * ctx
Definition: bench_impl.h:13
void bench_multiset_setup(void *arg)
Definition: bench_impl.h:40
void run_multiset_bench(int iters, int argc, char **argv)
Definition: bench_impl.h:44
#define UNUSED(x)
Definition: bench_impl.h:15
void bench_multiset(void *arg, int iters)
Definition: bench_impl.h:19
#define BUFSIZE
Definition: bench_impl.h:17
int have_flag(int argc, char **argv, char *flag)
Definition: bench.h:116
void run_benchmark(char *name, void(*benchmark)(void *, int), void(*setup)(void *), void(*teardown)(void *, int), void *data, int count, int iter)
Definition: bench.h:82
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 context object (created in dynamically allocated memory).
Definition: secp256k1.c:188
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
Definition: secp256k1.c:146
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
Definition: secp256k1.h:184
SECP256K1_API int secp256k1_multiset_init(const secp256k1_context *ctx, secp256k1_multiset *multiset) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Initialize a multiset The resulting multiset the multiset for no data elements.
Definition: main_impl.h:200
SECP256K1_API int secp256k1_multiset_finalize(const secp256k1_context *ctx, unsigned char *resultHash, const secp256k1_multiset *multiset) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Converts a multiset to a hash.
Definition: main_impl.h:165
SECP256K1_API int secp256k1_multiset_add(const secp256k1_context *ctx, secp256k1_multiset *multiset, const unsigned char *input, size_t inputLen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Adds an element to a multiset from single data element.
Definition: main_impl.h:127
Opaque multiset; this is actually a group element.