Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ bench: $(BENCH_BINARY) FORCE
bitcoin_bench_clean : FORCE
rm -f $(CLEAN_BITCOIN_BENCH) $(bench_bench_dash_OBJECTS) $(BENCH_BINARY)

%.raw.h: %.raw
bench/data/%.raw.h: bench/data/%.raw
@$(MKDIR_P) $(@D)
@{ \
echo "namespace raw_bench{" && \
echo "static unsigned const char $(*F)[] = {" && \
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
echo "};"; \
echo "};};"; \
} > "$@.new" && mv -f "$@.new" "$@"
@echo "Generated $@"
9 changes: 5 additions & 4 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ if EMBEDDED_UNIVALUE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
endif

%.json.h: %.json
test/data/%.json.h: test/data/%.json
@$(MKDIR_P) $(@D)
@{ \
echo "namespace json_tests{" && \
Expand All @@ -193,11 +193,12 @@ endif
} > "$@.new" && mv -f "$@.new" "$@"
@echo "Generated $@"

test/data/alertTests.raw.h: test/data/alertTests.raw
test/data/%.raw.h: test/data/%.raw
@$(MKDIR_P) $(@D)
@{ \
echo "namespace raw_tests{" && \
echo "static unsigned const char $(*F)[] = {" && \
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
echo "};"; \
$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' && \
echo "};};"; \
} > "$@.new" && mv -f "$@.new" "$@"
@echo "Generated $@"
14 changes: 6 additions & 8 deletions src/bench/checkblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,31 @@
#include "streams.h"
#include "consensus/validation.h"

namespace block_bench {
#include "bench/data/block413567.raw.h"
}

// 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
// compact block relay.

static void DeserializeBlockTest(benchmark::State& state)
{
CDataStream stream((const char*)block_bench::block413567,
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
CDataStream stream((const char*)raw_bench::block413567,
(const char*)&raw_bench::block413567[sizeof(raw_bench::block413567)],
SER_NETWORK, PROTOCOL_VERSION);
char a;
stream.write(&a, 1); // Prevent compaction

while (state.KeepRunning()) {
CBlock block;
stream >> block;
assert(stream.Rewind(sizeof(block_bench::block413567)));
assert(stream.Rewind(sizeof(raw_bench::block413567)));
}
}

static void DeserializeAndCheckBlockTest(benchmark::State& state)
{
CDataStream stream((const char*)block_bench::block413567,
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
CDataStream stream((const char*)raw_bench::block413567,
(const char*)&raw_bench::block413567[sizeof(raw_bench::block413567)],
SER_NETWORK, PROTOCOL_VERSION);
char a;
stream.write(&a, 1); // Prevent compaction
Expand All @@ -45,7 +43,7 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state)
while (state.KeepRunning()) {
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
stream >> block;
assert(stream.Rewind(sizeof(block_bench::block413567)));
assert(stream.Rewind(sizeof(raw_bench::block413567)));

CValidationState validationState;
assert(CheckBlock(block, validationState, params, block.GetBlockTime()));
Expand Down
2 changes: 1 addition & 1 deletion src/test/alert_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct ReadAlerts : public TestingSetup
{
ReadAlerts()
{
std::vector<unsigned char> vch(alertTests, alertTests + sizeof(alertTests));
std::vector<unsigned char> vch(raw_tests::alertTests, raw_tests::alertTests + sizeof(raw_tests::alertTests));
CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
try {
while (!stream.eof())
Expand Down