From: Otto Date: Fri, 22 Oct 2021 10:56:52 +0000 (+0200) Subject: Add speedtest for burtle and sip X-Git-Tag: rec-4.6.0-beta1~43^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f335d14f5549923c812c79d50fe5837ba51cadbc;p=thirdparty%2Fpdns.git Add speedtest for burtle and sip --- diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index f8ca9d5ec3..0cce35e466 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -15,6 +15,10 @@ #include "dns_random.hh" #include "arguments.hh" +#if defined(HAVE_LIBSODIUM) +#include +#endif + #ifndef RECURSOR #include "statbag.hh" #include "base64.hh" @@ -1090,6 +1094,51 @@ private: const std::string d_password{"test password"}; }; +struct BurtleHashTest +{ + explicit BurtleHashTest(const string& str) : d_name(str) {} + + string getName() const + { + return "BurtleHash"; + } + + void operator()() const + { + burtle(reinterpret_cast(d_name.data()), d_name.length(), 0); + + } + +private: + const string d_name; +}; + + +#if defined(HAVE_LIBSODIUM) +struct SipHashTest +{ + explicit SipHashTest(const string& str) : d_name(str) + { + crypto_shorthash_keygen(d_key); + } + + string getName() const + { + return "SipHash"; + } + + void operator()() const + { + unsigned char out[crypto_shorthash_BYTES]; + crypto_shorthash(out, reinterpret_cast(d_name.data()), d_name.length(), d_key); + } + +private: + const string d_name; + unsigned char d_key[crypto_shorthash_KEYBYTES]; +}; +#endif + int main(int argc, char** argv) try { @@ -1237,6 +1286,9 @@ try doRun(StatRingDNSNameQTypeTest(DNSName("example.com"), QType(1))); #endif + doRun(BurtleHashTest("a string of chars")); + doRun(SipHashTest("a string of chars")); + cerr<<"Total runs: " << g_totalRuns<