mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
merge bitcoin#16299: Move generated data to a dedicated translation unit
This commit is contained in:
parent
4bc0ae1ee2
commit
e51c4c41c0
@ -21,6 +21,8 @@ bench_bench_dash_SOURCES = \
|
|||||||
bench/bls_dkg.cpp \
|
bench/bls_dkg.cpp \
|
||||||
bench/checkblock.cpp \
|
bench/checkblock.cpp \
|
||||||
bench/checkqueue.cpp \
|
bench/checkqueue.cpp \
|
||||||
|
bench/data.h \
|
||||||
|
bench/data.cpp \
|
||||||
bench/duplicate_inputs.cpp \
|
bench/duplicate_inputs.cpp \
|
||||||
bench/ecdsa.cpp \
|
bench/ecdsa.cpp \
|
||||||
bench/examples.cpp \
|
bench/examples.cpp \
|
||||||
@ -83,7 +85,7 @@ CLEAN_BITCOIN_BENCH = bench/*.gcda bench/*.gcno $(GENERATED_BENCH_FILES)
|
|||||||
|
|
||||||
CLEANFILES += $(CLEAN_BITCOIN_BENCH)
|
CLEANFILES += $(CLEAN_BITCOIN_BENCH)
|
||||||
|
|
||||||
bench/checkblock.cpp: bench/data/block813851.raw.h
|
bench/data.cpp: bench/data/block813851.raw.h
|
||||||
|
|
||||||
bitcoin_bench: $(BENCH_BINARY)
|
bitcoin_bench: $(BENCH_BINARY)
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ bench/data/%.raw.h: bench/data/%.raw
|
|||||||
@$(MKDIR_P) $(@D)
|
@$(MKDIR_P) $(@D)
|
||||||
@{ \
|
@{ \
|
||||||
echo "namespace raw_bench{" && \
|
echo "namespace raw_bench{" && \
|
||||||
echo "static unsigned const char $(*F)[] = {" && \
|
echo "static unsigned const char $(*F)_raw[] = {" && \
|
||||||
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
|
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
|
||||||
echo "};};"; \
|
echo "};};"; \
|
||||||
} > "$@.new" && mv -f "$@.new" "$@"
|
} > "$@.new" && mv -f "$@.new" "$@"
|
||||||
|
@ -3,39 +3,34 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
|
#include <bench/data.h>
|
||||||
|
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
|
|
||||||
#include <bench/data/block813851.raw.h>
|
|
||||||
|
|
||||||
// These are the two major time-sinks which happen after we have fully received
|
// These are the two major time-sinks which happen after we have fully received
|
||||||
// a block off the wire, but before we can relay the block on to peers using
|
// a block off the wire, but before we can relay the block on to peers using
|
||||||
// compact block relay.
|
// compact block relay.
|
||||||
|
|
||||||
static void DeserializeBlockTest(benchmark::Bench& bench)
|
static void DeserializeBlockTest(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
CDataStream stream((const char*)raw_bench::block813851,
|
CDataStream stream(benchmark::data::block813851, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
(const char*)raw_bench::block813851+sizeof(raw_bench::block813851),
|
|
||||||
SER_NETWORK, PROTOCOL_VERSION);
|
|
||||||
char a = '\0';
|
char a = '\0';
|
||||||
stream.write(&a, 1); // Prevent compaction
|
stream.write(&a, 1); // Prevent compaction
|
||||||
|
|
||||||
bench.unit("block").run([&] {
|
bench.unit("block").run([&] {
|
||||||
CBlock block;
|
CBlock block;
|
||||||
stream >> block;
|
stream >> block;
|
||||||
bool rewound = stream.Rewind(sizeof(raw_bench::block813851));
|
bool rewound = stream.Rewind(benchmark::data::block813851.size());
|
||||||
assert(rewound);
|
assert(rewound);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
CDataStream stream((const char*)raw_bench::block813851,
|
CDataStream stream(benchmark::data::block813851, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
(const char*)raw_bench::block813851+sizeof(raw_bench::block813851),
|
|
||||||
SER_NETWORK, PROTOCOL_VERSION);
|
|
||||||
char a = '\0';
|
char a = '\0';
|
||||||
stream.write(&a, 1); // Prevent compaction
|
stream.write(&a, 1); // Prevent compaction
|
||||||
|
|
||||||
@ -44,7 +39,7 @@ static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
|||||||
bench.unit("block").run([&] {
|
bench.unit("block").run([&] {
|
||||||
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
||||||
stream >> block;
|
stream >> block;
|
||||||
bool rewound = stream.Rewind(sizeof(raw_bench::block813851));
|
bool rewound = stream.Rewind(benchmark::data::block813851.size());
|
||||||
assert(rewound);
|
assert(rewound);
|
||||||
|
|
||||||
CValidationState validationState;
|
CValidationState validationState;
|
||||||
|
14
src/bench/data.cpp
Normal file
14
src/bench/data.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#include <bench/data.h>
|
||||||
|
|
||||||
|
namespace benchmark {
|
||||||
|
namespace data {
|
||||||
|
|
||||||
|
#include <bench/data/block813851.raw.h>
|
||||||
|
const std::vector<uint8_t> block813851{raw_bench::block813851_raw, raw_bench::block813851_raw + sizeof(raw_bench::block813851_raw) / sizeof(raw_bench::block813851_raw[0])};
|
||||||
|
|
||||||
|
} // namespace data
|
||||||
|
} // namespace benchmark
|
19
src/bench/data.h
Normal file
19
src/bench/data.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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> block813851;
|
||||||
|
|
||||||
|
} // namespace data
|
||||||
|
} // namespace benchmark
|
||||||
|
|
||||||
|
#endif // BITCOIN_BENCH_DATA_H
|
Loading…
Reference in New Issue
Block a user