bench: Avoid tmp files in pwd

This commit is contained in:
MarcoFalke
2025-07-07 13:15:21 +02:00
parent e3f416dbf7
commit fa2fbaa4a2

View File

@@ -3,8 +3,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <util/fs.h>
#include <cstddef>
@@ -13,11 +13,11 @@
static void FindByte(benchmark::Bench& bench)
{
// Setup
AutoFile file{fsbridge::fopen("streams_tmp", "w+b")};
const auto testing_setup{MakeNoLogFileContext<const BasicTestingSetup>(ChainType::REGTEST)};
AutoFile file{fsbridge::fopen(testing_setup->m_path_root / "streams_tmp", "w+b")};
const size_t file_size = 200;
uint8_t data[file_size] = {0};
data[file_size-1] = 1;
data[file_size - 1] = 1;
file << data;
file.seek(0, SEEK_SET);
BufferedFile bf{file, /*nBufSize=*/file_size + 1, /*nRewindIn=*/file_size};
@@ -27,9 +27,7 @@ static void FindByte(benchmark::Bench& bench)
bf.FindByte(std::byte(1));
});
// Cleanup
assert(file.fclose() == 0);
fs::remove("streams_tmp");
}
BENCHMARK(FindByte, benchmark::PriorityLevel::HIGH);