xor.cpp
1 // Copyright (c) The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or https://opensource.org/license/mit/. 4 5 #include <bench/bench.h> 6 7 #include <random.h> 8 #include <streams.h> 9 10 #include <cstddef> 11 #include <vector> 12 13 static void Xor(benchmark::Bench& bench) 14 { 15 FastRandomContext frc{/*fDeterministic=*/true}; 16 auto data{frc.randbytes<std::byte>(1024)}; 17 auto key{frc.randbytes<std::byte>(31)}; 18 19 bench.batch(data.size()).unit("byte").run([&] { 20 util::Xor(data, key); 21 }); 22 } 23 24 BENCHMARK(Xor, benchmark::PriorityLevel::HIGH);