aboutsummaryrefslogtreecommitdiff
path: root/src/bench/xor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bench/xor.cpp')
-rw-r--r--src/bench/xor.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bench/xor.cpp b/src/bench/xor.cpp
new file mode 100644
index 0000000000..edda74214a
--- /dev/null
+++ b/src/bench/xor.cpp
@@ -0,0 +1,24 @@
+// Copyright (c) The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or https://opensource.org/license/mit/.
+
+#include <bench/bench.h>
+
+#include <random.h>
+#include <streams.h>
+
+#include <cstddef>
+#include <vector>
+
+static void Xor(benchmark::Bench& bench)
+{
+ FastRandomContext frc{/*fDeterministic=*/true};
+ auto data{frc.randbytes<std::byte>(1024)};
+ auto key{frc.randbytes<std::byte>(31)};
+
+ bench.batch(data.size()).unit("byte").run([&] {
+ util::Xor(data, key);
+ });
+}
+
+BENCHMARK(Xor, benchmark::PriorityLevel::HIGH);