File tree Expand file tree Collapse file tree 12 files changed +24
-54
lines changed Expand file tree Collapse file tree 12 files changed +24
-54
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,10 @@ function(generate_header_from_json json_source_relpath)
1111 )
1212endfunction ()
1313
14- function (generate_header_from_raw raw_source_relpath)
14+ function (generate_header_from_raw raw_source_relpath raw_namespace )
1515 add_custom_command (
1616 OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /${raw_source_relpath} .h
17- COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR} /${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR} /${raw_source_relpath} .h -P ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
17+ COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR} /${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR} /${raw_source_relpath} .h -DRAW_NAMESPACE= ${raw_namespace} - P ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
1818 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${raw_source_relpath} ${PROJECT_SOURCE_DIR} /cmake/script/GenerateHeaderFromRaw.cmake
1919 VERBATIM
2020 )
Original file line number Diff line number Diff line change 55file (READ ${RAW_SOURCE_PATH} hex_content HEX)
66string (REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content} " )
77
8+ file (WRITE ${HEADER_PATH} "#include <cstddef>\n " )
9+ file (APPEND ${HEADER_PATH} "#include <span>\n " )
10+ file (APPEND ${HEADER_PATH} "namespace ${RAW_NAMESPACE} {\n " )
811get_filename_component (raw_source_basename ${RAW_SOURCE_PATH} NAME_WE )
9- file (WRITE ${HEADER_PATH} "static unsigned const char ${raw_source_basename} _raw[] = {\n " )
12+ file (APPEND ${HEADER_PATH} "inline constexpr std::byte detail_ ${raw_source_basename} _raw[]{\n " )
1013
1114set (i 0)
1215foreach (byte ${bytes} )
1316 math (EXPR i "${i} + 1" )
1417 math (EXPR remainder "${i} % 8" )
1518 if (remainder EQUAL 0)
16- file (APPEND ${HEADER_PATH} "0x${byte} ,\n " )
19+ file (APPEND ${HEADER_PATH} "std::byte{ 0x${byte} },\n " )
1720 else ()
18- file (APPEND ${HEADER_PATH} "0x${byte} , " )
21+ file (APPEND ${HEADER_PATH} "std::byte{ 0x${byte} }, " )
1922 endif ()
2023endforeach ()
2124
22- file (APPEND ${HEADER_PATH} "\n };" )
25+ file (APPEND ${HEADER_PATH} "\n };\n " )
26+ file (APPEND ${HEADER_PATH} "inline constexpr std::span ${raw_source_basename} {detail_${raw_source_basename} _raw};\n " )
27+ file (APPEND ${HEADER_PATH} "}" )
Original file line number Diff line number Diff line change 33# file COPYING or https://opensource.org/license/mit/.
44
55include (GenerateHeaders)
6- generate_header_from_raw(data/block413567.raw)
6+ generate_header_from_raw(data/block413567.raw benchmark::data )
77
88add_executable (bench_bitcoin
99 bench_bitcoin.cpp
1010 bench.cpp
11- data.cpp
1211 nanobench.cpp
1312 ${CMAKE_CURRENT_BINARY_DIR} /data/block413567.raw.h
1413# Benchmarks:
Original file line number Diff line number Diff line change 33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < bench/bench.h>
6- #include < bench/data.h>
6+ #include < bench/data/block413567.raw .h>
77#include < chainparams.h>
88#include < common/args.h>
99#include < consensus/validation.h>
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 33// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44
55#include < bench/bench.h>
6- #include < bench/data.h>
6+ #include < bench/data/block413567.raw .h>
77#include < chainparams.h>
88#include < flatfile.h>
99#include < node/blockstorage.h>
Original file line number Diff line number Diff line change 33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < bench/bench.h>
6- #include < bench/data.h>
6+ #include < bench/data/block413567.raw .h>
77#include < flatfile.h>
88#include < node/blockstorage.h>
99#include < primitives/block.h>
Original file line number Diff line number Diff line change 33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < bench/bench.h>
6- #include < bench/data.h>
6+ #include < bench/data/block413567.raw .h>
77#include < chain.h>
88#include < core_io.h>
99#include < primitives/block.h>
Original file line number Diff line number Diff line change 33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < bench/bench.h>
6- #include < bench/data.h>
6+ #include < bench/data/block413567.raw .h>
77#include < span.h>
88#include < util/strencodings.h>
99
You can’t perform that action at this time.
0 commit comments