diff options
Diffstat (limited to 'cpp/src/tests')
26 files changed, 178 insertions, 245 deletions
diff --git a/cpp/src/tests/asyncstore.cmake b/cpp/src/tests/asyncstore.cmake index 3dcd81c3d7..795ea55cf7 100644 --- a/cpp/src/tests/asyncstore.cmake +++ b/cpp/src/tests/asyncstore.cmake @@ -22,19 +22,17 @@ # New journal perf test (jrnl2Perf) set (jrnl2Perf_SOURCES - storePerftools/jrnlPerf/Journal.cpp - storePerftools/jrnlPerf/JournalParameters.cpp - storePerftools/jrnlPerf/PerfTest.cpp - storePerftools/jrnlPerf/TestResult.cpp + storePerftools/jrnlPerf/Journal.cpp + storePerftools/jrnlPerf/JournalParameters.cpp + storePerftools/jrnlPerf/PerfTest.cpp + storePerftools/jrnlPerf/TestResult.cpp - storePerftools/common/Parameters.cpp storePerftools/common/PerftoolError.cpp - storePerftools/common/ScopedTimable.cpp - storePerftools/common/ScopedTimer.cpp - storePerftools/common/Streamable.cpp - storePerftools/common/TestParameters.cpp - storePerftools/common/TestResult.cpp - storePerftools/common/Thread.cpp + storePerftools/common/ScopedTimable.cpp + storePerftools/common/ScopedTimer.cpp + storePerftools/common/Streamable.cpp + storePerftools/common/TestParameters.cpp + storePerftools/common/Thread.cpp ) if (UNIX) @@ -47,33 +45,23 @@ if (UNIX) qpidbroker rt ) + add_test (Store_Perftools_Smoke_Test ${CMAKE_CURRENT_SOURCE_DIR}/storePerftools/storePerftoolsSmokeTest.sh) endif (UNIX) # Async store perf test (asyncPerf) set (asyncStorePerf_SOURCES storePerftools/asyncPerf/MessageConsumer.cpp storePerftools/asyncPerf/MessageProducer.cpp - storePerftools/asyncPerf/PerfTest.cpp -# storePerftools/asyncPerf/SimpleDeliverable.cpp -# storePerftools/asyncPerf/SimpleDeliveryRecord.cpp -# storePerftools/asyncPerf/SimpleMessage.cpp -# storePerftools/asyncPerf/SimpleMessageAsyncContext.cpp -# storePerftools/asyncPerf/SimpleMessageDeque.cpp -# storePerftools/asyncPerf/SimpleQueue.cpp -# storePerftools/asyncPerf/SimpleQueuedMessage.cpp -# storePerftools/asyncPerf/SimpleTxnAccept.cpp -# storePerftools/asyncPerf/SimpleTxnPublish.cpp - storePerftools/asyncPerf/TestOptions.cpp - storePerftools/asyncPerf/TestResult.cpp + storePerftools/asyncPerf/PerfTest.cpp + storePerftools/asyncPerf/TestOptions.cpp + storePerftools/asyncPerf/TestResult.cpp - storePerftools/common/Parameters.cpp storePerftools/common/PerftoolError.cpp - storePerftools/common/ScopedTimable.cpp - storePerftools/common/ScopedTimer.cpp - storePerftools/common/Streamable.cpp - storePerftools/common/TestOptions.cpp - storePerftools/common/TestResult.cpp - storePerftools/common/Thread.cpp + storePerftools/common/ScopedTimable.cpp + storePerftools/common/ScopedTimer.cpp + storePerftools/common/Streamable.cpp + storePerftools/common/TestOptions.cpp + storePerftools/common/Thread.cpp ) if (UNIX) diff --git a/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.cpp b/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.cpp index 6477696bd6..cc24500800 100644 --- a/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.cpp +++ b/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.cpp @@ -43,7 +43,8 @@ MessageConsumer::MessageConsumer(const TestOptions& perfTestParams, m_perfTestParams(perfTestParams), m_store(store), m_resultQueue(arq), - m_queue(queue) + m_queue(queue), + m_stopFlag(false) {} MessageConsumer::~MessageConsumer() {} @@ -56,6 +57,11 @@ MessageConsumer::record(boost::shared_ptr<qpid::broker::SimpleDeliveryRecord> dr void MessageConsumer::commitComplete() {} +void +MessageConsumer::stop() { + m_stopFlag = true; +} + void* MessageConsumer::runConsumers() { const bool useTxns = m_perfTestParams.m_deqTxnBlockSize > 0U; @@ -68,7 +74,7 @@ MessageConsumer::runConsumers() { uint32_t msgsPerConsumer = m_perfTestParams.m_numEnqThreadsPerQueue * m_perfTestParams.m_numMsgs / m_perfTestParams.m_numDeqThreadsPerQueue; uint32_t numMsgs = 0UL; - while (numMsgs < msgsPerConsumer) { + while (numMsgs < msgsPerConsumer && !m_stopFlag) { if (m_queue->dispatch(*this)) { ++numMsgs; if (useTxns) { @@ -78,7 +84,7 @@ MessageConsumer::runConsumers() { tb->enlist(ta); if (++opsInTxnCnt >= m_perfTestParams.m_deqTxnBlockSize) { tb->commitLocal(m_store); - if (numMsgs < m_perfTestParams.m_numMsgs) { + if (numMsgs < msgsPerConsumer) { tb = new qpid::broker::SimpleTxnBuffer(m_resultQueue); } opsInTxnCnt = 0U; @@ -95,7 +101,7 @@ MessageConsumer::runConsumers() { } } - if (opsInTxnCnt) { + if (opsInTxnCnt && !m_stopFlag) { tb->commitLocal(m_store); } diff --git a/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.h b/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.h index d5a881f7e0..93c1543b79 100644 --- a/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.h +++ b/cpp/src/tests/storePerftools/asyncPerf/MessageConsumer.h @@ -53,6 +53,7 @@ public: virtual ~MessageConsumer(); void record(boost::shared_ptr<qpid::broker::SimpleDeliveryRecord> dr); void commitComplete(); + void stop(); void* runConsumers(); static void* startConsumers(void* ptr); @@ -62,6 +63,7 @@ private: qpid::broker::AsyncResultQueue& m_resultQueue; boost::shared_ptr<qpid::broker::SimpleQueue> m_queue; std::deque<boost::shared_ptr<qpid::broker::SimpleDeliveryRecord> > m_unacked; + bool m_stopFlag; }; }}} // namespace tests::storePerftools::asyncPerf diff --git a/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.cpp b/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.cpp index f88d305a38..b9a5e2a211 100644 --- a/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.cpp +++ b/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.cpp @@ -45,11 +45,17 @@ MessageProducer::MessageProducer(const TestOptions& perfTestParams, m_msgData(msgData), m_store(store), m_resultQueue(arq), - m_queue(queue) + m_queue(queue), + m_stopFlag(false) {} MessageProducer::~MessageProducer() {} +void +MessageProducer::stop() { + m_stopFlag = true; +} + void* MessageProducer::runProducers() { const bool useTxns = m_perfTestParams.m_enqTxnBlockSize > 0U; @@ -58,7 +64,7 @@ MessageProducer::runProducers() { if (useTxns) { tb = new qpid::broker::SimpleTxnBuffer(m_resultQueue); } - for (uint32_t numMsgs=0; numMsgs<m_perfTestParams.m_numMsgs; ++numMsgs) { + for (uint32_t numMsgs=0; numMsgs<m_perfTestParams.m_numMsgs && !m_stopFlag; ++numMsgs) { boost::intrusive_ptr<qpid::broker::SimpleMessage> msg(new qpid::broker::SimpleMessage(m_msgData, m_perfTestParams.m_msgSize, m_store)); if (useTxns) { boost::shared_ptr<qpid::broker::SimpleTxnPublish> op(new qpid::broker::SimpleTxnPublish(msg)); @@ -79,7 +85,7 @@ MessageProducer::runProducers() { m_queue->deliver(msg); } } - if (recsInTxnCnt) { + if (recsInTxnCnt && !m_stopFlag) { tb->commitLocal(m_store); } return reinterpret_cast<void*>(0); @@ -87,8 +93,7 @@ MessageProducer::runProducers() { //static void* -MessageProducer::startProducers(void* ptr) -{ +MessageProducer::startProducers(void* ptr) { return reinterpret_cast<MessageProducer*>(ptr)->runProducers(); } diff --git a/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.h b/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.h index 6f98d03503..a6e6bb7f28 100644 --- a/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.h +++ b/cpp/src/tests/storePerftools/asyncPerf/MessageProducer.h @@ -49,6 +49,8 @@ public: qpid::broker::AsyncResultQueue& arq, boost::shared_ptr<qpid::broker::SimpleQueue> queue); virtual ~MessageProducer(); + void stop(); + void* runProducers(); static void* startProducers(void* ptr); private: @@ -57,6 +59,7 @@ private: qpid::broker::AsyncStore* m_store; qpid::broker::AsyncResultQueue& m_resultQueue; boost::shared_ptr<qpid::broker::SimpleQueue> m_queue; + bool m_stopFlag; }; }}} // namespace tests::storePerftools::asyncPerf diff --git a/cpp/src/tests/storePerftools/asyncPerf/PerfTest.cpp b/cpp/src/tests/storePerftools/asyncPerf/PerfTest.cpp index c05eb0487d..3cd4eefbd9 100644 --- a/cpp/src/tests/storePerftools/asyncPerf/PerfTest.cpp +++ b/cpp/src/tests/storePerftools/asyncPerf/PerfTest.cpp @@ -170,32 +170,31 @@ runPerfTest(int argc, char** argv) { opts.parse(argc, argv); aso.validate(); to.validate(); - } - catch (std::exception& e) { - std::cerr << e.what() << std::endl; - return 1; - } - // Handle options that just print information then exit. - if (co.version) { - std::cout << tests::storePerftools::name() << " v." << tests::storePerftools::version() << std::endl; - return 0; - } - if (co.help) { - std::cout << tests::storePerftools::name() << ": asyncPerf" << std::endl; - std::cout << "Performance test for the async store through the qpid async store interface." << std::endl; - std::cout << "Usage: asyncPerf [options]" << std::endl; - std::cout << opts << std::endl; - return 0; - } + // Handle options that just print information then exit. + if (co.version) { + std::cout << tests::storePerftools::name() << " v." << tests::storePerftools::version() << std::endl; + return 0; + } + if (co.help) { + std::cout << tests::storePerftools::name() << ": asyncPerf" << std::endl; + std::cout << "Performance test for the async store through the qpid async store interface." << std::endl; + std::cout << "Usage: asyncPerf [options]" << std::endl; + std::cout << opts << std::endl; + return 0; + } - // Create and start test - tests::storePerftools::asyncPerf::PerfTest apt(to, aso); - apt.run(); + // Create and start test + tests::storePerftools::asyncPerf::PerfTest apt(to, aso); + apt.run(); - // Print test result - std::cout << apt << std::endl; - //::sleep(1); + // Print test result + std::cout << apt << std::endl; + //::sleep(1); + } catch (const std::exception& e) { + std::cerr << e.what() << std::endl; + return 1; + } return 0; } diff --git a/cpp/src/tests/storePerftools/common/Parameters.cpp b/cpp/src/tests/storePerftools/common/Parameters.cpp deleted file mode 100644 index 8e4bafaf86..0000000000 --- a/cpp/src/tests/storePerftools/common/Parameters.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * \file Parameters.cpp - */ - -#include "Parameters.h" - -namespace tests { -namespace storePerftools { -namespace common { - -Parameters::~Parameters() -{} - -}}} // namespace tests::storePerftools::common diff --git a/cpp/src/tests/storePerftools/common/Parameters.h b/cpp/src/tests/storePerftools/common/Parameters.h index 941cce2dc6..cc3bf5d0f6 100644 --- a/cpp/src/tests/storePerftools/common/Parameters.h +++ b/cpp/src/tests/storePerftools/common/Parameters.h @@ -20,6 +20,7 @@ /** * \file Parameters.h */ + #ifndef tests_storePerftools_common_Parameters_h_ #define tests_storePerftools_common_Parameters_h_ @@ -32,7 +33,7 @@ namespace common { class Parameters: public Streamable { public: - virtual ~Parameters(); + virtual ~Parameters() {} virtual bool parseArg(const int arg, const char* optarg) = 0; diff --git a/cpp/src/tests/storePerftools/common/PerftoolError.cpp b/cpp/src/tests/storePerftools/common/PerftoolError.cpp index 9edf384b07..8830447062 100644 --- a/cpp/src/tests/storePerftools/common/PerftoolError.cpp +++ b/cpp/src/tests/storePerftools/common/PerftoolError.cpp @@ -92,49 +92,41 @@ PerftoolError::PerftoolError(const uint32_t errCode, m_throwingFunction(throwingFunction) {} -PerftoolError::~PerftoolError() throw() -{} +PerftoolError::~PerftoolError() throw() {} const char* -PerftoolError::what() const throw () -{ +PerftoolError::what() const throw () { return m_what.c_str(); } uint32_t -PerftoolError::getErrorCode() const throw () -{ +PerftoolError::getErrorCode() const throw () { return m_errCode; } const std::string -PerftoolError::getAdditionalInfo() const throw () -{ +PerftoolError::getAdditionalInfo() const throw () { return m_errMsg; } const std::string -PerftoolError::getThrowingClass() const throw () -{ +PerftoolError::getThrowingClass() const throw () { return m_throwingClass; } const std::string -PerftoolError::getThrowingFunction() const throw () -{ +PerftoolError::getThrowingFunction() const throw () { return m_throwingFunction; } void -PerftoolError::toStream(std::ostream& os) const -{ +PerftoolError::toStream(std::ostream& os) const { os << what(); } // private void -PerftoolError::formatWhatStr() throw () -{ +PerftoolError::formatWhatStr() throw () { try { const bool ai = !m_errMsg.empty(); const bool tc = !m_throwingClass.empty(); @@ -164,8 +156,7 @@ PerftoolError::formatWhatStr() throw () // private const char* -PerftoolError::className() -{ +PerftoolError::className() { return s_className; } @@ -182,8 +173,7 @@ const uint32_t PerftoolError::PERR_PTHREAD = 0x0001; // static const char* -PerftoolError::s_errorMessage(const uint32_t err_no) throw () -{ +PerftoolError::s_errorMessage(const uint32_t err_no) throw () { s_errorMapIterator = s_errorMap.find(err_no); if (s_errorMapIterator == s_errorMap.end()) return "<Unknown error code>"; @@ -192,8 +182,7 @@ PerftoolError::s_errorMessage(const uint32_t err_no) throw () // private static bool -PerftoolError::s_initialize() -{ +PerftoolError::s_initialize() { s_errorMap[PERR_PTHREAD] = "ERR_PTHREAD: pthread operation failure"; return true; diff --git a/cpp/src/tests/storePerftools/common/PerftoolError.h b/cpp/src/tests/storePerftools/common/PerftoolError.h index 913bbbb7be..268835b58d 100644 --- a/cpp/src/tests/storePerftools/common/PerftoolError.h +++ b/cpp/src/tests/storePerftools/common/PerftoolError.h @@ -61,7 +61,8 @@ namespace tests { namespace storePerftools { namespace common { -class PerftoolError: public std::runtime_error, public Streamable +class PerftoolError: public std::runtime_error, + public Streamable { public: // --- Constructors & destructors --- diff --git a/cpp/src/tests/storePerftools/common/ScopedTimable.cpp b/cpp/src/tests/storePerftools/common/ScopedTimable.cpp index c2023b7854..924879411f 100644 --- a/cpp/src/tests/storePerftools/common/ScopedTimable.cpp +++ b/cpp/src/tests/storePerftools/common/ScopedTimable.cpp @@ -31,12 +31,10 @@ ScopedTimable::ScopedTimable() : m_elapsed(0.0) {} -ScopedTimable::~ScopedTimable() -{} +ScopedTimable::~ScopedTimable() {} double& -ScopedTimable::getElapsedRef() -{ +ScopedTimable::getElapsedRef() { return m_elapsed; } diff --git a/cpp/src/tests/storePerftools/common/ScopedTimer.cpp b/cpp/src/tests/storePerftools/common/ScopedTimer.cpp index 143588941c..b919ea21ce 100644 --- a/cpp/src/tests/storePerftools/common/ScopedTimer.cpp +++ b/cpp/src/tests/storePerftools/common/ScopedTimer.cpp @@ -41,16 +41,14 @@ ScopedTimer::ScopedTimer(ScopedTimable& st) : ::clock_gettime(CLOCK_REALTIME, &m_startTime); } -ScopedTimer::~ScopedTimer() -{ +ScopedTimer::~ScopedTimer() { ::timespec stopTime; ::clock_gettime(CLOCK_REALTIME, &stopTime); m_elapsed = _s_getDoubleTime(stopTime) - _s_getDoubleTime(m_startTime); } // private static -double ScopedTimer::_s_getDoubleTime(const ::timespec& ts) -{ +double ScopedTimer::_s_getDoubleTime(const ::timespec& ts) { return ts.tv_sec + (double(ts.tv_nsec) / 1e9); } diff --git a/cpp/src/tests/storePerftools/common/Streamable.cpp b/cpp/src/tests/storePerftools/common/Streamable.cpp index 8c58f1c03e..8b5427c508 100644 --- a/cpp/src/tests/storePerftools/common/Streamable.cpp +++ b/cpp/src/tests/storePerftools/common/Streamable.cpp @@ -30,23 +30,20 @@ namespace storePerftools { namespace common { std::string -Streamable::toString() const -{ +Streamable::toString() const { std::ostringstream oss; toStream(oss); return oss.str(); } std::ostream& -operator<<(std::ostream& os, const Streamable& s) -{ +operator<<(std::ostream& os, const Streamable& s) { s.toStream(os); return os; } std::ostream& -operator<<(std::ostream& os, const Streamable* sPtr) -{ +operator<<(std::ostream& os, const Streamable* sPtr) { sPtr->toStream(os); return os; } diff --git a/cpp/src/tests/storePerftools/common/TestOptions.cpp b/cpp/src/tests/storePerftools/common/TestOptions.cpp index 5e72fafc6f..c0c8b284d3 100644 --- a/cpp/src/tests/storePerftools/common/TestOptions.cpp +++ b/cpp/src/tests/storePerftools/common/TestOptions.cpp @@ -61,12 +61,10 @@ TestOptions::TestOptions(const uint32_t numMsgs, doAddOptions(); } -TestOptions::~TestOptions() -{} +TestOptions::~TestOptions() {} void -TestOptions::printVals(std::ostream& os) const -{ +TestOptions::printVals(std::ostream& os) const { os << "TEST OPTIONS:" << std::endl; os << " Number of queues [-q, --num-queues]: " << m_numQueues << std::endl; os << " Number of producers per queue [-p, --num-producers]: " << m_numEnqThreadsPerQueue << std::endl; @@ -76,8 +74,7 @@ TestOptions::printVals(std::ostream& os) const } void -TestOptions::validate() -{ +TestOptions::validate() { if (((m_numEnqThreadsPerQueue * m_numMsgs) % m_numDeqThreadsPerQueue) != 0) { throw qpid::Exception("Parameter Error: (num-producers * num-msgs) must be a multiple of num-consumers."); } @@ -85,8 +82,7 @@ TestOptions::validate() // private void -TestOptions::doAddOptions() -{ +TestOptions::doAddOptions() { addOptions() ("num-queues,q", qpid::optValue(m_numQueues, "N"), "Number of queues") diff --git a/cpp/src/tests/storePerftools/common/TestParameters.cpp b/cpp/src/tests/storePerftools/common/TestParameters.cpp index f36a2d3bda..e418eedefb 100644 --- a/cpp/src/tests/storePerftools/common/TestParameters.cpp +++ b/cpp/src/tests/storePerftools/common/TestParameters.cpp @@ -67,12 +67,10 @@ TestParameters::TestParameters(const TestParameters& tp): m_numDeqThreadsPerQueue(tp.m_numDeqThreadsPerQueue) {} -TestParameters::~TestParameters() -{} +TestParameters::~TestParameters() {} void -TestParameters::toStream(std::ostream& os) const -{ +TestParameters::toStream(std::ostream& os) const { os << "Test Parameters:" << std::endl; os << " num_msgs = " << m_numMsgs << std::endl; os << " msg_size = " << m_msgSize << std::endl; @@ -83,8 +81,7 @@ TestParameters::toStream(std::ostream& os) const bool TestParameters::parseArg(const int arg, - const char* optarg) -{ + const char* optarg) { switch(arg) { case 'm': m_numMsgs = uint32_t(std::atol(optarg)); @@ -109,8 +106,7 @@ TestParameters::parseArg(const int arg, // static void -TestParameters::printArgs(std::ostream& os) -{ +TestParameters::printArgs(std::ostream& os) { os << "Test parameters:" << std::endl; os << " -m --num_msgs: Number of messages to send per enqueue thread [" << TestParameters::s_defaultNumMsgs << "]" << std::endl; @@ -127,8 +123,7 @@ TestParameters::printArgs(std::ostream& os) // static std::string -TestParameters::shortArgs() -{ +TestParameters::shortArgs() { return "m:S:q:e:d:"; } diff --git a/cpp/src/tests/storePerftools/common/TestResult.cpp b/cpp/src/tests/storePerftools/common/TestResult.cpp deleted file mode 100644 index c3e9d27dfc..0000000000 --- a/cpp/src/tests/storePerftools/common/TestResult.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * \file TestResult.cpp - */ - -#include "TestResult.h" - -namespace tests { -namespace storePerftools { -namespace common { - -TestResult::TestResult() : - ScopedTimable(), - Streamable() -{} - -TestResult::~TestResult() -{} - -}}} // namespace tests::storePerftools::common diff --git a/cpp/src/tests/storePerftools/common/TestResult.h b/cpp/src/tests/storePerftools/common/TestResult.h index e878164837..5092477397 100644 --- a/cpp/src/tests/storePerftools/common/TestResult.h +++ b/cpp/src/tests/storePerftools/common/TestResult.h @@ -34,8 +34,7 @@ namespace common { class TestResult : public ScopedTimable, public Streamable { public: - TestResult(); - virtual ~TestResult(); + virtual ~TestResult() {} void toStream(std::ostream& os = std::cout) const = 0; }; diff --git a/cpp/src/tests/storePerftools/common/Thread.cpp b/cpp/src/tests/storePerftools/common/Thread.cpp index 188e102e8f..cab7d77297 100644 --- a/cpp/src/tests/storePerftools/common/Thread.cpp +++ b/cpp/src/tests/storePerftools/common/Thread.cpp @@ -45,21 +45,19 @@ Thread::Thread(Thread::startFn_t sf, PTHREAD_CHK(::pthread_create(&m_thread, NULL, sf, p), "::pthread_create", "Thread", "Thread"); } -Thread::~Thread() -{ +Thread::~Thread() { if (m_running) { PTHREAD_CHK(::pthread_detach(m_thread), "pthread_detach", "~Thread", "Thread"); } } const std::string& -Thread::getId() const -{ +Thread::getId() const { return m_id; } -void Thread::join() -{ +void +Thread::join() { PTHREAD_CHK(::pthread_join(m_thread, NULL), "pthread_join", "join", "Thread"); m_running = false; } diff --git a/cpp/src/tests/storePerftools/common/Thread.h b/cpp/src/tests/storePerftools/common/Thread.h index 74d25a9da0..e133ddecc5 100644 --- a/cpp/src/tests/storePerftools/common/Thread.h +++ b/cpp/src/tests/storePerftools/common/Thread.h @@ -36,7 +36,8 @@ namespace common { /** * \brief Ultra-simple pthread class. */ -class Thread { +class Thread +{ public: typedef void*(*startFn_t)(void*); ///< Thread entry point function pointer type diff --git a/cpp/src/tests/storePerftools/jrnlPerf/Journal.cpp b/cpp/src/tests/storePerftools/jrnlPerf/Journal.cpp index 6efdc06fc8..8207249600 100644 --- a/cpp/src/tests/storePerftools/jrnlPerf/Journal.cpp +++ b/cpp/src/tests/storePerftools/jrnlPerf/Journal.cpp @@ -70,8 +70,7 @@ Journal::Journal(const uint32_t numMsgs, m_jrnlPtr(jrnlPtr) {} -Journal::~Journal() -{ +Journal::~Journal() { delete m_jrnlPtr; } @@ -80,8 +79,7 @@ Journal::~Journal() // This method will be called by multiple threads simultaneously // Enqueue thread entry point void* -Journal::runEnqueues() -{ +Journal::runEnqueues() { bool misfireFlag = false; uint32_t i = 0; while (i < m_numMsgs) { @@ -122,8 +120,7 @@ Journal::runEnqueues() // This method will be called by multiple threads simultaneously // Dequeue thread entry point void* -Journal::runDequeues() -{ +Journal::runDequeues() { uint32_t i = 0; X_JRNL_IO_OP_RES jrnlIoRes; while (i < m_numMsgs) { @@ -170,23 +167,20 @@ Journal::runDequeues() //static void* -Journal::startEnqueues(void* ptr) -{ +Journal::startEnqueues(void* ptr) { return reinterpret_cast<Journal*>(ptr)->runEnqueues(); } //static void* -Journal:: startDequeues(void* ptr) -{ +Journal:: startDequeues(void* ptr) { return reinterpret_cast<Journal*>(ptr)->runDequeues(); } // *** MUST BE THREAD-SAFE **** // This method will be called by multiple threads simultaneously void -Journal::X_AIO_WR_CALLBACK(std::vector<X_DATA_TOKEN*>& msgTokenList) -{ +Journal::X_AIO_WR_CALLBACK(std::vector<X_DATA_TOKEN*>& msgTokenList) { X_DATA_TOKEN* mtokPtr; while (msgTokenList.size()) { mtokPtr = msgTokenList.back(); @@ -212,7 +206,6 @@ Journal::X_AIO_WR_CALLBACK(std::vector<X_DATA_TOKEN*>& msgTokenList) // *** MUST BE THREAD-SAFE **** // This method will be called by multiple threads simultaneously void -Journal::X_AIO_RD_CALLBACK(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/) -{} +Journal::X_AIO_RD_CALLBACK(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/) {} }}} // namespace tests::storePerftools::jrnlPerf diff --git a/cpp/src/tests/storePerftools/jrnlPerf/Journal.h b/cpp/src/tests/storePerftools/jrnlPerf/Journal.h index 4803e4ecf6..4c02127af1 100644 --- a/cpp/src/tests/storePerftools/jrnlPerf/Journal.h +++ b/cpp/src/tests/storePerftools/jrnlPerf/Journal.h @@ -161,7 +161,6 @@ private: std::vector<X_DATA_TOKEN*> m_unprocCallbacks; ///< List of unprocessed callbacks to be dequeued X_SCOPED_MUTEX m_unprocCallbacksMutex; ///< Mutex which protects the unprocessed callback queue - }; }}} // namespace tests::storePerftools::jrnlPerf diff --git a/cpp/src/tests/storePerftools/jrnlPerf/JournalParameters.cpp b/cpp/src/tests/storePerftools/jrnlPerf/JournalParameters.cpp index 2b07619041..1d595f44ac 100644 --- a/cpp/src/tests/storePerftools/jrnlPerf/JournalParameters.cpp +++ b/cpp/src/tests/storePerftools/jrnlPerf/JournalParameters.cpp @@ -93,12 +93,10 @@ JournalParameters::JournalParameters(const JournalParameters& jp) : #endif {} -JournalParameters::~JournalParameters() -{} +JournalParameters::~JournalParameters() {} void -JournalParameters::toStream(std::ostream& os) const -{ +JournalParameters::toStream(std::ostream& os) const { os << "Journal Parameters:" << std::endl; os << " jrnlDir = \"" << m_jrnlDir << "\"" << std::endl; os << " jrnlBaseFileName = \"" << m_jrnlBaseFileName << "\"" << std::endl; @@ -110,8 +108,7 @@ JournalParameters::toStream(std::ostream& os) const bool JournalParameters::parseArg(const int arg, - const char* optarg) -{ + const char* optarg) { switch(arg) { case 'j': m_jrnlDir.assign(optarg); @@ -139,8 +136,7 @@ JournalParameters::parseArg(const int arg, // static void -JournalParameters::printArgs(std::ostream& os) -{ +JournalParameters::printArgs(std::ostream& os) { os << "Journal parameters:" << std::endl; os << " -j --jrnl_dir: Store directory [\"" << JournalParameters::s_defaultJrnlDir << "\"]" << std::endl; @@ -158,8 +154,7 @@ JournalParameters::printArgs(std::ostream& os) // static std::string -JournalParameters::shortArgs() -{ +JournalParameters::shortArgs() { return "j:b:f:s:p:c:"; } diff --git a/cpp/src/tests/storePerftools/jrnlPerf/PerfTest.cpp b/cpp/src/tests/storePerftools/jrnlPerf/PerfTest.cpp index ba7c95e821..6da0205e49 100644 --- a/cpp/src/tests/storePerftools/jrnlPerf/PerfTest.cpp +++ b/cpp/src/tests/storePerftools/jrnlPerf/PerfTest.cpp @@ -66,15 +66,13 @@ PerfTest::PerfTest(const tests::storePerftools::common::TestParameters& tp, m_msgData(new char[tp.m_msgSize]) {} -PerfTest::~PerfTest() -{ +PerfTest::~PerfTest() { delete[] m_msgData; } // private void -PerfTest::prepareJournals(std::vector<Journal*>& jrnlList) -{ +PerfTest::prepareJournals(std::vector<Journal*>& jrnlList) { #ifdef JOURNAL2 if (qpid::asyncStore::jrnl2::JournalDirectory::s_exists(m_jrnlParams.m_jrnlDir)) { qpid::asyncStore::jrnl2::JournalDirectory::s_destroy(m_jrnlParams.m_jrnlDir); @@ -114,8 +112,7 @@ PerfTest::prepareJournals(std::vector<Journal*>& jrnlList) // private void -PerfTest::destroyJournals(std::vector<Journal*>& jrnlList) -{ +PerfTest::destroyJournals(std::vector<Journal*>& jrnlList) { while (jrnlList.size()) { delete jrnlList.back(); jrnlList.pop_back(); @@ -123,8 +120,7 @@ PerfTest::destroyJournals(std::vector<Journal*>& jrnlList) } void -PerfTest::run() -{ +PerfTest::run() { std::vector<Journal*> jrnlList; prepareJournals(jrnlList); @@ -154,16 +150,14 @@ PerfTest::run() } void -PerfTest::toStream(std::ostream& os) const -{ +PerfTest::toStream(std::ostream& os) const { os << m_testParams << std::endl; os << m_jrnlParams << std::endl; os << m_testResult << std::endl; } void -printArgs(std::ostream& os) -{ +printArgs(std::ostream& os) { os << " -h --help: This help message" << std::endl; os << std::endl; @@ -178,8 +172,7 @@ bool readArgs(int argc, char** argv, tests::storePerftools::common::TestParameters& tp, - JournalParameters& jp) -{ + JournalParameters& jp) { /// \todo TODO: At some point, find an easy way to aggregate these from JrnlPerfTestParameters and JrnlParameters themselves. static struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -231,8 +224,7 @@ readArgs(int argc, // ----------------------------------------------------------------- int -main(int argc, char** argv) -{ +main(int argc, char** argv) { tests::storePerftools::common::TestParameters tp; tests::storePerftools::jrnlPerf::JournalParameters jp; if (tests::storePerftools::jrnlPerf::readArgs(argc, argv, tp, jp)) return 1; diff --git a/cpp/src/tests/storePerftools/jrnlPerf/TestResult.cpp b/cpp/src/tests/storePerftools/jrnlPerf/TestResult.cpp index 9fe214726d..b5d84a6ac4 100644 --- a/cpp/src/tests/storePerftools/jrnlPerf/TestResult.cpp +++ b/cpp/src/tests/storePerftools/jrnlPerf/TestResult.cpp @@ -34,12 +34,10 @@ TestResult::TestResult(const tests::storePerftools::common::TestParameters& tp) m_testParams(tp) {} -TestResult::~TestResult() -{} +TestResult::~TestResult() {} void -TestResult::toStream(std::ostream& os) const -{ +TestResult::toStream(std::ostream& os) const { double msgsRate; os << "TEST RESULTS:" << std::endl; os << " Msgs per thread: " << m_testParams.m_numMsgs << std::endl; diff --git a/cpp/src/tests/storePerftools/storePerftoolsSmokeTest.sh b/cpp/src/tests/storePerftools/storePerftoolsSmokeTest.sh new file mode 100755 index 0000000000..592e1e60a0 --- /dev/null +++ b/cpp/src/tests/storePerftools/storePerftoolsSmokeTest.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +run_test() { + local cmd=$1 + echo $cmd + $cmd + if (( $? != 0 )); then + exit 1 + fi +} + +NUM_MSGS=1000 +TEST_PROG="./asyncStorePerf" + +run_test "${TEST_PROG}" +run_test "${TEST_PROG} --help" +for q in 1 2; do + for p in 1 2; do + for c in 1 2; do + for e in 0 1 3; do + for d in 0 1 3; do + for dur in "" "--durable"; do + run_test "${TEST_PROG} --num-queues $q --num-msgs ${NUM_MSGS} --num-producers $p --num-consumers $c --enq-txn-size $e --deq-txn-size $d ${dur}" + done + done + done + done + done +done + + +NUM_MSGS=1000 +TEST_PROG="./jrnl2Perf" + + +run_test "${TEST_PROG}" + +# This test returns 1, don't use run_test until this is fixed. +cmd="${TEST_PROG} --help" +echo $cmd +$cmd + +for q in 1 2; do + for p in 1 2; do + for c in 1; do # BUG - this will fail for c > 1 + run_test "./jrnl2Perf --num_queues $q --num_msgs ${NUM_MSGS} --num_enq_threads_per_queue $p --num_deq_threads_per_queue $c" + done + done +done + +#exit 0 diff --git a/cpp/src/tests/storePerftools/version.h b/cpp/src/tests/storePerftools/version.h index 311b145330..be28f5bc57 100644 --- a/cpp/src/tests/storePerftools/version.h +++ b/cpp/src/tests/storePerftools/version.h @@ -31,8 +31,8 @@ namespace tests { namespace storePerftools { static const int versionMajor = 0; -static const int versionMinor = 0; -static const int versionRevision = 1; +static const int versionMinor = 1; +static const int versionRevision = 0; std::string name() { return "Qpid async store perftools"; |
