Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
bench
poly1305.cpp
Go to the documentation of this file.
1
// Copyright (c) 2019-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
6
#include <
bench/bench.h
>
7
#include <
crypto/poly1305.h
>
8
#include <
span.h
>
9
10
#include <cstddef>
11
#include <cstdint>
12
#include <vector>
13
14
/* Number of bytes to process per iteration */
15
static
constexpr
uint64_t
BUFFER_SIZE_TINY
= 64;
16
static
constexpr
uint64_t
BUFFER_SIZE_SMALL
= 256;
17
static
constexpr
uint64_t
BUFFER_SIZE_LARGE
= 1024*1024;
18
19
static
void
POLY1305
(
benchmark::Bench
& bench,
size_t
buffersize)
20
{
21
std::vector<std::byte> tag(
Poly1305::TAGLEN
, {});
22
std::vector<std::byte> key(
Poly1305::KEYLEN
, {});
23
std::vector<std::byte> in(buffersize, {});
24
bench.
batch
(in.size()).
unit
(
"byte"
).
run
([&] {
25
Poly1305
{key}.
Update
(in).
Finalize
(tag);
26
});
27
}
28
29
static
void
POLY1305_64BYTES
(
benchmark::Bench
& bench)
30
{
31
POLY1305
(bench,
BUFFER_SIZE_TINY
);
32
}
33
34
static
void
POLY1305_256BYTES
(
benchmark::Bench
& bench)
35
{
36
POLY1305
(bench,
BUFFER_SIZE_SMALL
);
37
}
38
39
static
void
POLY1305_1MB
(
benchmark::Bench
& bench)
40
{
41
POLY1305
(bench,
BUFFER_SIZE_LARGE
);
42
}
43
44
BENCHMARK
(
POLY1305_64BYTES
);
45
BENCHMARK
(
POLY1305_256BYTES
);
46
BENCHMARK
(
POLY1305_1MB
);
bench.h
BENCHMARK
#define BENCHMARK(n)
Definition
bench.h:68
BUFFER_SIZE_LARGE
static const uint64_t BUFFER_SIZE_LARGE
Definition
chacha20.cpp:18
BUFFER_SIZE_TINY
static const uint64_t BUFFER_SIZE_TINY
Definition
chacha20.cpp:16
BUFFER_SIZE_SMALL
static const uint64_t BUFFER_SIZE_SMALL
Definition
chacha20.cpp:17
POLY1305_256BYTES
static void POLY1305_256BYTES(benchmark::Bench &bench)
Definition
poly1305.cpp:34
POLY1305
static void POLY1305(benchmark::Bench &bench, size_t buffersize)
Definition
poly1305.cpp:19
POLY1305_64BYTES
static void POLY1305_64BYTES(benchmark::Bench &bench)
Definition
poly1305.cpp:29
POLY1305_1MB
static void POLY1305_1MB(benchmark::Bench &bench)
Definition
poly1305.cpp:39
Poly1305
C++ wrapper with std::byte span interface around poly1305_donna code.
Definition
poly1305.h:39
Poly1305::Finalize
void Finalize(std::span< std::byte > out) noexcept
Write authentication tag to 16-byte out.
Definition
poly1305.h:64
Poly1305::Update
Poly1305 & Update(std::span< const std::byte > msg) noexcept
Process message bytes.
Definition
poly1305.h:57
Poly1305::KEYLEN
static constexpr unsigned KEYLEN
Length of the keys expected by the constructor.
Definition
poly1305.h:47
Poly1305::TAGLEN
static constexpr unsigned TAGLEN
Length of the output produced by Finalize().
Definition
poly1305.h:44
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition
nanobench.h:627
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition
nanobench.h:1234
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition
nanobench.h:1258
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
poly1305.h
span.h
Generated on
for Bitcoin Core by
1.17.0