Files
chaos/ChaosBenches/Hash/Md4HasherBenches.cpp
hashlag ff57cd0d31
All checks were successful
ChaosBenchmark CI / build-and-benchmark (push) Successful in 57s
ChaosTest CI / build-and-test (push) Successful in 54s
Fix #includes: Add <cstring> for strlen()
2026-01-25 17:35:53 +03:00

32 lines
1.2 KiB
C++

#include <benchmark/benchmark.h>
#include <cstring>
#include <Hash/Md4.hpp>
using namespace Chaos::Hash::Md4;
static void Md4HasherCreateComputeDeleteBench(benchmark::State & state)
{
const char * data
= "All states, all powers, that have held and hold rule over men have been and are either republics or principalities.\n"
"Principalities are either hereditary, in which the family has been long established; or they are new.\n"
"The new are either entirely new, as was Milan to Francesco Sforza, or they are, as it were, members annexed to the hereditary state of the "
"prince who has acquired them, as was the kingdom of Naples to that of the King of Spain.\n"
"Such dominions thus acquired are either accustomed to live under a prince, or to live in freedom; and are acquired either by the arms of the "
"prince himself, or of others, or else by fortune or by ability.";
const size_t dataLen = strlen(data);
for (auto _ : state)
{
Md4Hasher hasher;
hasher.Update(data, data + dataLen);
Md4Hash result = hasher.Finish();
benchmark::DoNotOptimize(result);
}
}
BENCHMARK(Md4HasherCreateComputeDeleteBench);
BENCHMARK_MAIN();