Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2019-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <bench/bench.h>6#include <crypto/poly1305.h>7#include <util/byte_units.h>9#include <cstddef>10#include <cstdint>11#include <span>12#include <vector>14/* Number of bytes to process per iteration */15static constexpr uint64_t BUFFER_SIZE_TINY = 64;16static constexpr uint64_t BUFFER_SIZE_SMALL = 256;17static constexpr uint64_t BUFFER_SIZE_LARGE{1_MiB};19static void POLY1305(benchmark::Bench& bench, size_t buffersize)20{21std::vector<std::byte> tag(Poly1305::TAGLEN, {});22std::vector<std::byte> key(Poly1305::KEYLEN, {});23std::vector<std::byte> in(buffersize, {});24bench.batch(in.size()).unit("byte").run([&] {25Poly1305{key}.Update(in).Finalize(tag);26});27}29static void POLY1305_64BYTES(benchmark::Bench& bench)30{31POLY1305(bench, BUFFER_SIZE_TINY);32}34static void POLY1305_256BYTES(benchmark::Bench& bench)35{36POLY1305(bench, BUFFER_SIZE_SMALL);37}39static void POLY1305_1MB(benchmark::Bench& bench)40{41POLY1305(bench, BUFFER_SIZE_LARGE);42}44BENCHMARK(POLY1305_64BYTES);45BENCHMARK(POLY1305_256BYTES);46BENCHMARK(POLY1305_1MB);
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.