Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
bench_multiset.c
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#include "include/secp256k1.h"
9#include "util.h"
10#include "bench.h"
11
13
14#define UNUSED(x) (void)(x)
15
16#define BUFSIZE (3 * 32)
17
18void bench_multiset(void* arg, int iters) {
19 int it = 0;
20 int n, m;
21 unsigned char result[32];
23
24 UNUSED(arg);
26
27 for (m = 0; m < iters; m++) {
28 unsigned char buf[BUFSIZE];
29 for (n = 0; n < BUFSIZE; n++) {
30 buf[n] = it++;
31 }
32
33 secp256k1_multiset_add(ctx, &multiset, buf, sizeof(buf));
34 }
35
37}
38
40 UNUSED(arg);
41}
42
static void run_benchmark(char *name, void(*benchmark)(void *), void(*setup)(void *), void(*teardown)(void *), void *data, int count, int iter)
Definition bench.c:26
secp256k1_context * ctx
void bench_multiset_setup(void *arg)
int main(void)
#define UNUSED(x)
void bench_multiset(void *arg, int iters)
#define BUFSIZE
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
int get_iters(int default_iters)
Definition bench.h:124
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:152
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
Definition secp256k1.h:173
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object (created in dynamically allocated memory).
Definition secp256k1.c:196
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.