test: Use span for raw data

This change allows to drop brittle sizeof calls in favor of the
std::span::size method.

Other improvements include:

* Use of a namespace to mark test and bench data
* Use of the modern std::byte
* Drop of a no longer used std::vector copy and the bench/data module
This commit is contained in:
MarcoFalke
2024-09-03 15:33:08 +02:00
parent fac973647d
commit faecca9a85
12 changed files with 24 additions and 54 deletions

View File

@@ -3,12 +3,11 @@
# file COPYING or https://opensource.org/license/mit/.
include(GenerateHeaders)
generate_header_from_raw(data/block413567.raw)
generate_header_from_raw(data/block413567.raw benchmark::data)
add_executable(bench_bitcoin
bench_bitcoin.cpp
bench.cpp
data.cpp
nanobench.cpp
${CMAKE_CURRENT_BINARY_DIR}/data/block413567.raw.h
# Benchmarks:

View File

@@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chainparams.h>
#include <common/args.h>
#include <consensus/validation.h>

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2019-2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/data.h>
#include <iterator>
namespace benchmark {
namespace data {
#include <bench/data/block413567.raw.h>
const std::vector<uint8_t> block413567{std::begin(block413567_raw), std::end(block413567_raw)};
} // namespace data
} // namespace benchmark

View File

@@ -1,19 +0,0 @@
// Copyright (c) 2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BENCH_DATA_H
#define BITCOIN_BENCH_DATA_H
#include <cstdint>
#include <vector>
namespace benchmark {
namespace data {
extern const std::vector<uint8_t> block413567;
} // namespace data
} // namespace benchmark
#endif // BITCOIN_BENCH_DATA_H

View File

@@ -3,7 +3,7 @@
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chainparams.h>
#include <flatfile.h>
#include <node/blockstorage.h>

View File

@@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <flatfile.h>
#include <node/blockstorage.h>
#include <primitives/block.h>

View File

@@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <chain.h>
#include <core_io.h>
#include <primitives/block.h>

View File

@@ -3,7 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <bench/data.h>
#include <bench/data/block413567.raw.h>
#include <span.h>
#include <util/strencodings.h>