Bitcoin ABC 0.32.4
P2P Digital Currency
poly1305.cpp
Go to the documentation of this file.
1// Copyright (c) 2019 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#include <iostream>
6
7#include <bench/bench.h>
8#include <crypto/poly1305.h>
9
10#include <span.h>
11
12/* Number of bytes to process per iteration */
13static constexpr uint64_t BUFFER_SIZE_TINY = 64;
14static constexpr uint64_t BUFFER_SIZE_SMALL = 256;
15static constexpr uint64_t BUFFER_SIZE_LARGE = 1024 * 1024;
16
17static void POLY1305(benchmark::Bench &bench, size_t buffersize) {
18 std::vector<std::byte> tag(Poly1305::TAGLEN, {});
19 std::vector<std::byte> key(Poly1305::KEYLEN, {});
20 std::vector<std::byte> in(buffersize, {});
21 bench.batch(in.size()).unit("byte").run(
22 [&] { Poly1305{key}.Update(in).Finalize(tag); });
23}
24
27}
28
31}
32
33static void POLY1305_1MB(benchmark::Bench &bench) {
35}
36
static constexpr uint64_t BUFFER_SIZE_LARGE
Definition: poly1305.cpp:15
static constexpr uint64_t BUFFER_SIZE_TINY
Definition: poly1305.cpp:13
BENCHMARK(POLY1305_64BYTES)
static constexpr uint64_t BUFFER_SIZE_SMALL
Definition: poly1305.cpp:14
static void POLY1305_256BYTES(benchmark::Bench &bench)
Definition: poly1305.cpp:29
static void POLY1305(benchmark::Bench &bench, size_t buffersize)
Definition: poly1305.cpp:17
static void POLY1305_64BYTES(benchmark::Bench &bench)
Definition: poly1305.cpp:25
static void POLY1305_1MB(benchmark::Bench &bench)
Definition: poly1305.cpp:33
C++ wrapper with std::byte Span interface around poly1305_donna code.
Definition: poly1305.h:38
static constexpr unsigned KEYLEN
Length of the keys expected by the constructor.
Definition: poly1305.h:46
Poly1305 & Update(Span< const std::byte > msg) noexcept
Process message bytes.
Definition: poly1305.h:55
static constexpr unsigned TAGLEN
Length of the output produced by Finalize().
Definition: poly1305.h:43
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:616
ANKERL_NANOBENCH(NODISCARD) std Bench & batch(T b) noexcept
Sets the batch size.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1183
Bench & unit(char const *unit)
Sets the operation unit.