From: Remi Gacogne Date: Thu, 5 Aug 2021 09:22:19 +0000 (+0200) Subject: Add a sample (disabled) benchmark test for the multiplexer X-Git-Tag: dnsdist-1.7.0-alpha1~61^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5dc40dee9845cca979881c94d376976bef4341b;p=thirdparty%2Fpdns.git Add a sample (disabled) benchmark test for the multiplexer --- diff --git a/pdns/test-mplexer.cc b/pdns/test-mplexer.cc index fefdc54779..7fe483d4bd 100644 --- a/pdns/test-mplexer.cc +++ b/pdns/test-mplexer.cc @@ -302,4 +302,100 @@ BOOST_AUTO_TEST_CASE(test_MPlexer_ReadAndWrite) } } +#if 0 +BOOST_AUTO_TEST_CASE(test_MPlexer_Bench) +{ + const size_t count = 10000; + struct socket_pair + { + int sockets[2]; + }; + + std::vector pairs(count); + auto readCB = [](int fd, FDMultiplexer::funcparam_t& param) { + auto calledPtr = boost::any_cast(param); + *calledPtr = true; + }; + auto writeCB = [](int fd, FDMultiplexer::funcparam_t& param) { + auto calledPtr = boost::any_cast(param); + *calledPtr = true; + }; + bool readCBCalled = false; + bool writeCBCalled = false; + struct timeval now; + gettimeofday(&now, nullptr); + struct timeval ttd = now; + ttd.tv_sec += 3600; + DTime dt; + std::vector readyFDs; + readyFDs.reserve(count * 2); + + for (const auto& entry : FDMultiplexer::getMultiplexerMap()) { + auto mplexer = std::unique_ptr(entry.second()); + BOOST_REQUIRE(mplexer != nullptr); + cerr<<"Testing multiplexer "<getName()<<" performances"<addReadFD(pair.sockets[0], + readCB, + &readCBCalled, + &ttd); + mplexer->addWriteFD(pair.sockets[0], + writeCB, + &writeCBCalled, + &ttd); + } + cerr<<"Adding "<<(count*2)<<" events took "<getAvailableFDs(readyFDs, 0); + cerr<<"Checking readiness for "<<(count*2)<<" events ("<run(&now, 100); + cerr<<"Calling run() for "<<(count*2)<<" events ("<removeReadFD(pair.sockets[0]); + mplexer->removeWriteFD(pair.sockets[0]); + } + cerr<<"Removing "<<(count)<<" events took "<getAvailableFDs(readyFDs, 0); + cerr<<"Checking readiness for "<<(count)<<" events ("<run(&now, 100); + cerr<<"Calling run() for "<<(count)<<" events ("<removeReadFD(pair.sockets[0]); + } + cerr<<"Removing "<<(count)<<" events took "<