From 7008da430d9032ca55dda472be379bbeddd2e589 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Fri, 10 Jan 2025 11:29:14 +0000 Subject: [PATCH] HPCC-32126 9.4.x mismerge fix Signed-off-by: Jake Smith --- testing/unittests/jlibtests.cpp | 115 -------------------------------- 1 file changed, 115 deletions(-) diff --git a/testing/unittests/jlibtests.cpp b/testing/unittests/jlibtests.cpp index b0815ca60ea..a9d8f9610f3 100644 --- a/testing/unittests/jlibtests.cpp +++ b/testing/unittests/jlibtests.cpp @@ -4662,121 +4662,6 @@ class JLibSecretsTest : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_REGISTRATION( JLibSecretsTest ); CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( JLibSecretsTest, "JLibSecretsTest" ); -class HashFuncTests : public CppUnit::TestFixture -{ -public: - virtual void setUp() override - { - generateFixedRandomNullTermiantedStrings(); - } - - CPPUNIT_TEST_SUITE(HashFuncTests); - CPPUNIT_TEST(fnvTests); - CPPUNIT_TEST_SUITE_END(); - -protected: - static constexpr unsigned maxCalls = 10'000'000; - static constexpr unsigned minLen = 5, maxLen = 100; - static constexpr unsigned lenRange = maxLen - minLen + 1; - static constexpr unsigned randomSeed = 42; - static constexpr size_t testBufferSize = 1'000'000; - CCycleTimer timer; - std::vector buffer; - - unsigned getOffsetLenHash(unsigned offset, unsigned hash) - { - hash ^= (offset * 0x27D4EB2D); // use MurMurHash3 multiplier to introduce more randomness - hash *= fnvPrime32; - return hash; - } - void generateFixedRandomNullTermiantedStrings() - { - buffer.resize(testBufferSize); - std::mt19937 rng(randomSeed); - std::uniform_int_distribution dist(1, 255); - - unsigned offset = 0; - unsigned lenHash = fnvInitialHash32; - while (offset < testBufferSize) - { - // create str lengths between min and max based on offset, - // so that we can predictably read them back - lenHash = getOffsetLenHash(offset, lenHash); - unsigned len = (lenHash % lenRange) + minLen; - - if (offset + len + 1 >= testBufferSize) - break; - - for (unsigned i=0; i - void testHashc() - { - unsigned hashResult = fnvInitialHash32; - - unsigned offset = 0; - for (unsigned i=0; i buffer.size()) - offset = 0; - - hashResult ^= HASHCFUNC(&buffer[offset], len, hashResult); - offset += len; - } - CPPUNIT_ASSERT(hashResult != 0); - } - template - void testHashcz() - { - unsigned hashResult = fnvInitialHash32; - - unsigned lenHash = fnvInitialHash32; - unsigned offset = 0; - for (unsigned i=0; i buffer.size()) - { - offset = 0; - lenHash = getOffsetLenHash(offset, fnvInitialHash32); - len = (lenHash % lenRange) + minLen; - } - dbgassertex(len == strlen((const char *)&buffer[offset])); - hashResult ^= HASHCZFUNC(&buffer[offset], hashResult); - offset += len + 1; - } - CPPUNIT_ASSERT(hashResult != 0); - } - void measure(const char *funcName, const std::function &func) - { - timer.reset(); - func(); - unsigned elapsed = timer.elapsedMs(); - double throughput = static_cast(maxCalls) / elapsed * 1000; - PROGLOG("%s: %u calls took %u ms (%.2f hashes/sec)", funcName, maxCalls, elapsed, throughput); - } - void fnvTests() - { - measure("deprecatedHashc (fnv1)", [this]() { testHashc(); }); - measure("deprecatedHashcz (fnv1)", [this]() { testHashcz(); }); - measure("hashc (fnv1)", [this]() { testHashc(); }); - measure("hashcz (fnv1)", [this]() { testHashcz(); }); - measure("hashc_fnv1a", [this]() { testHashc(); }); - measure("hashcz_fnv1a", [this]() { testHashcz(); }); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( HashFuncTests ); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HashFuncTests, "HashFuncTests" ); class JLibStringTest : public CppUnit::TestFixture {