[rhmessaging-commits] rhmessaging commits: r4430 - in store/trunk/cpp: lib/jrnl2 and 1 other directories.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Dec 8 11:26:10 EST 2010


Author: kpvdr
Date: 2010-12-08 11:26:09 -0500 (Wed, 08 Dec 2010)
New Revision: 4430

Added:
   store/trunk/cpp/perf/JournalPerformanceTest.cpp
   store/trunk/cpp/perf/JournalPerformanceTest.hpp
   store/trunk/cpp/perf/PerformanceResult.cpp
   store/trunk/cpp/perf/PerformanceResult.hpp
   store/trunk/cpp/perf/ScopedTimable.hpp
   store/trunk/cpp/perf/ScopedTimer.cpp
   store/trunk/cpp/perf/ScopedTimer.hpp
   store/trunk/cpp/perf/Streamable.cpp
   store/trunk/cpp/perf/Streamable.hpp
Removed:
   store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
   store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
   store/trunk/cpp/perf/StorePerformanceTest.cpp
   store/trunk/cpp/perf/StorePerformanceTest.hpp
Modified:
   store/trunk/cpp/docs/Makefile.am
   store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
   store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
   store/trunk/cpp/perf/JournalInstance.cpp
   store/trunk/cpp/perf/JournalInstance.hpp
   store/trunk/cpp/perf/JournalParameters.cpp
   store/trunk/cpp/perf/JournalParameters.hpp
   store/trunk/cpp/perf/Makefile.am
   store/trunk/cpp/perf/TestParameters.cpp
   store/trunk/cpp/perf/TestParameters.hpp
   store/trunk/cpp/perf/m
Log:
Perf code refactor and tidy-up and removed creation of postscript docs (which don't work properly on RHEL4/5)

Modified: store/trunk/cpp/docs/Makefile.am
===================================================================
--- store/trunk/cpp/docs/Makefile.am	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/docs/Makefile.am	2010-12-08 16:26:09 UTC (rev 4430)
@@ -41,9 +41,9 @@
 	@doxygen jrnl_tmpl.dox
 # FIXME: doxygen seems to create files that do not compile under latex on 64-bit
 # so the following section is disabled until this is sorted out.
-	@make -C latex
+#	@make -C latex
 #	@cd latex; dvipdf refman.dvi refman.pdf
-	@cd latex; dvips refman.dvi -o refman.ps
+#	@cd latex; dvips refman.dvi -o refman.ps
 #	@ln -fs latex/refman.pdf rhmj.pdf
 #	@ln -fs latex/refman.ps rhmj.ps
 else

Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -89,21 +89,41 @@
 
 {}
 
+void
+JournalParameters::toStream(std::ostream& os) const
+{
+    os << "Store Parameters:" << std::endl;
+    os << "  jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+    os << "  jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+    os << "  numJrnlFiles = " << _numJrnlFiles << std::endl;
+    os << "  jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+    os << "  autoExpand = " << _autoExpand << std::endl;
+    os << "  autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+    os << "  writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+    os << "  writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+}
+
 std::string
-JournalParameters::toString()
+JournalParameters::toString() const
 {
     std::ostringstream oss;
-    oss << "Store Parameters:" << std::endl;
-    oss << "  jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
-    oss << "  jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
-    oss << "  numJrnlFiles = " << _numJrnlFiles << std::endl;
-    oss << "  jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
-    oss << "  autoExpand = " << _autoExpand << std::endl;
-    oss << "  autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
-    oss << "  writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
-    oss << "  writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+    toStream(oss);
     return oss.str();
 }
 
+std::ostream&
+operator<<(std::ostream& os, const JournalParameters& jp)
+{
+    jp.toStream(os);
+    return os;
+}
+
+std::ostream&
+operator<<(std::ostream& os, const JournalParameters* jpPtr)
+{
+    jpPtr->toStream(os);
+    return os;
+}
+
 } // namespace journal2
 } // namespace mrg

Modified: store/trunk/cpp/lib/jrnl2/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl2/JournalParameters.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/lib/jrnl2/JournalParameters.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -32,6 +32,7 @@
 #ifndef mrg_journal2_JournalParameters_hpp
 #define mrg_journal2_JournalParameters_hpp
 
+#include <iostream>
 #include <string>
 #include <sys/types.h>
 
@@ -70,7 +71,11 @@
                           const u_int16_t writeBuffNumPgs,
                           const u_int32_t writeBuffPgSize_sblks);
         JournalParameters(const JournalParameters& sp);
-        std::string toString();
+        void toStream(std::ostream& os = std::cout) const;
+        std::string toString() const;
+
+        friend std::ostream& operator<<(std::ostream& os, const JournalParameters& jp);
+        friend std::ostream& operator<<(std::ostream& os, const JournalParameters* jpPtr);
     };
 
 } // namespace journal2

Modified: store/trunk/cpp/perf/JournalInstance.cpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalInstance.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -38,216 +38,214 @@
 namespace jtest
 {
 
-JournalInstance::JournalInstance(const uint32_t numMsgs,
-                                 const uint32_t msgSize,
-                                 const char* msgData,
+    JournalInstance::JournalInstance(const uint32_t numMsgs,
+                                     const uint32_t msgSize,
+                                     const char* msgData,
 #ifdef JOURNAL2
-                                 mrg::journal2::jrnl* const jrnlPtr) :
+                                     mrg::journal2::jrnl* const jrnlPtr) :
 #else
-                                 mrg::journal::jcntl* const jrnlPtr) :
+                                     mrg::journal::jcntl* const jrnlPtr) :
 #endif
-                                 _numMsgs(numMsgs),
-                                 _msgSize(msgSize),
-                                 _msgData(msgData),
-                                 _jrnlPtr(jrnlPtr),
-                                 _threadSwitch(false)
-{}
+                                     _numMsgs(numMsgs),
+                                     _msgSize(msgSize),
+                                     _msgData(msgData),
+                                     _jrnlPtr(jrnlPtr),
+                                     _threadSwitch(false)
+    {}
 
-JournalInstance::~JournalInstance()
-{
-    delete _jrnlPtr;
-}
+    JournalInstance::~JournalInstance()
+    {
+        delete _jrnlPtr;
+    }
 
 
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Enqueue thread entry point
-void
-JournalInstance::_doEnqueues()
-{
-    bool misfireFlag = false;
-    uint32_t i = 0;
-    while (i < _numMsgs) {
+    // *** MUST BE THREAD-SAFE ****
+    // This method will be called by multiple threads simultaneously
+    // Enqueue thread entry point
+    void
+    JournalInstance::_doEnqueues()
+    {
+        bool misfireFlag = false;
+        uint32_t i = 0;
+        while (i < _numMsgs) {
 #ifdef JOURNAL2
-        mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
-        mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
+            mrg::journal2::dtok* dtokPtr = new mrg::journal2::dtok();
+            mrg::journal2::iores jrnlIoRes = _jrnlPtr->enqueue(_msgData, _msgSize, dtokPtr);
 #else
-        mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
-        mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
+            mrg::journal::data_tok* dtokPtr = new mrg::journal::data_tok();
+            mrg::journal::iores jrnlIoRes = _jrnlPtr->enqueue_data_record(_msgData, _msgSize, _msgSize, dtokPtr);
 #endif
-        switch (jrnlIoRes) {
+            switch (jrnlIoRes) {
 #ifdef JOURNAL2
-            case 0:
+                case 0:
 #else
-            case mrg::journal::RHM_IORES_SUCCESS:
+                case mrg::journal::RHM_IORES_SUCCESS:
 #endif
-                i++;
-                misfireFlag = false;
-                break;
+                    i++;
+                    misfireFlag = false;
+                    break;
 #ifdef JOURNAL2
-            case mrg::journal2::RHM_IORES_BUSY:
+                case mrg::journal2::RHM_IORES_BUSY:
 #else
-            case mrg::journal::RHM_IORES_BUSY:
+                case mrg::journal::RHM_IORES_BUSY:
 #endif
-                if (!misfireFlag) std::cout << "-" << std::flush;
-                delete dtokPtr;
-                misfireFlag = true;
-                break;
+                    if (!misfireFlag) std::cout << "-" << std::flush;
+                    delete dtokPtr;
+                    misfireFlag = true;
+                    break;
 #ifdef JOURNAL2
-            case mrg::journal2::RHM_IORES_ENQCAPTHRESH:
+                case mrg::journal2::RHM_IORES_ENQCAPTHRESH:
 #else
-            case mrg::journal::RHM_IORES_ENQCAPTHRESH:
+                case mrg::journal::RHM_IORES_ENQCAPTHRESH:
 #endif
-                //std::cout << "_doEnqueues() RHM_IORES_ENQCAPTHRESH: " << dtokPtr->status_str() << std::endl;
-                if (!misfireFlag) std::cout << "*" << std::flush;
-                //std::cout << ".";
-                delete dtokPtr;
-                misfireFlag = true;
-                ::usleep(10);
-                break;
-            default:
-                delete dtokPtr;
+                    //std::cout << "_doEnqueues() RHM_IORES_ENQCAPTHRESH: " << dtokPtr->status_str() << std::endl;
+                    if (!misfireFlag) std::cout << "*" << std::flush;
+                    //std::cout << ".";
+                    delete dtokPtr;
+                    misfireFlag = true;
+                    ::usleep(10);
+                    break;
+                default:
+                    delete dtokPtr;
 #ifdef JOURNAL2
-                std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
+                    std::cerr << "enqueue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << std::endl;
 #else
-                std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
+                    std::cerr << "enqueue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << std::endl;
 #endif
+            }
         }
+        _jrnlPtr->flush(false);
     }
-    _jrnlPtr->flush(false);
-}
 
 
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Dequeue thread entry point
-void
-JournalInstance::_doDequeues()
-{
-    uint32_t i = 0;
-    while (i < _numMsgs) {
+    // *** MUST BE THREAD-SAFE ****
+    // This method will be called by multiple threads simultaneously
+    // Dequeue thread entry point
+    void
+    JournalInstance::_doDequeues()
+    {
+        uint32_t i = 0;
+        while (i < _numMsgs) {
 #ifdef JOURNAL2
-        mrg::journal2::dtok* dtokPtr = 0;
+            mrg::journal2::dtok* dtokPtr = 0;
 #else
-        mrg::journal::data_tok* dtokPtr = 0;
+            mrg::journal::data_tok* dtokPtr = 0;
 #endif
-        while (!dtokPtr) {
-            bool getEventsFlag;
-            {
-                std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
-                getEventsFlag = _unprocCallbackList.size() == 0;
-                if (!getEventsFlag) {
-                    dtokPtr = _unprocCallbackList.front();
-                    _unprocCallbackList.pop();
+            while (!dtokPtr) {
+                bool getEventsFlag; // thread local
+                { // --- START OF CRITICAL SECTION ---
+                    std::lock_guard<std::mutex> l(_unprocCallbackListMutex);
+                    getEventsFlag = _unprocCallbackList.size() == 0;
+                    if (!getEventsFlag) {
+                        dtokPtr = _unprocCallbackList.front();
+                        _unprocCallbackList.pop();
+                    }
+                } // --- END OF CRITICAL SECTION ---
+                if (getEventsFlag) {
+                    _jrnlPtr->get_wr_events(0);
+                    ::usleep(1);
                 }
             }
-            if (getEventsFlag) {
-                _jrnlPtr->get_wr_events(0);
-                ::usleep(1);
-            }
-        }
-        bool done = false;
-        while (!done) {
+            bool done = false;
+            while (!done) {
 #ifdef JOURNAL2
-            mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
+                mrg::journal2::iores jrnlIoRes = _jrnlPtr->dequeue(dtokPtr);
 #else
-            mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
+                mrg::journal::iores jrnlIoRes = _jrnlPtr->dequeue_data_record(dtokPtr);
 #endif
-            switch (jrnlIoRes) {
+                switch (jrnlIoRes) {
 #ifdef JOURNAL2
-                case 0:
+                    case 0:
 #else
-                case mrg::journal::RHM_IORES_SUCCESS:
+                    case mrg::journal::RHM_IORES_SUCCESS:
 #endif
-                    i ++;
-                    done = true;
-                    break;
+                        i ++;
+                        done = true;
+                        break;
 #ifdef JOURNAL2
-                case mrg::journal2::RHM_IORES_BUSY:
+                    case mrg::journal2::RHM_IORES_BUSY:
 #else
-                case mrg::journal::RHM_IORES_BUSY:
+                    case mrg::journal::RHM_IORES_BUSY:
 #endif
-                    //::usleep(10);
-                    break;
-                default:
+                        //::usleep(10);
+                        break;
+                    default:
 #ifdef JOURNAL2
-                    std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
-                              << dtokPtr->status_str() << std::endl;
+                        std::cerr << "dequeue_data_record FAILED with " << mrg::journal2::iores_str(jrnlIoRes) << ": "
+                                  << dtokPtr->status_str() << std::endl;
 #else
-                    std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
-                              << dtokPtr->status_str() << std::endl;
+                        std::cerr << "dequeue_data_record FAILED with " << mrg::journal::iores_str(jrnlIoRes) << ": "
+                                  << dtokPtr->status_str() << std::endl;
 #endif
-                    delete dtokPtr;
-                    done = true;
+                        delete dtokPtr;
+                        done = true;
+                }
             }
+            _jrnlPtr->get_wr_events(0);
         }
-        _jrnlPtr->get_wr_events(0);
+        _jrnlPtr->flush(true);
     }
-    _jrnlPtr->flush(true);
-}
 
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-// Main thread entry point.
-// _threadSwitch flips on each call; this makes alternate threads run _doEnqueues() and _doDequeues()
-void
-JournalInstance::operator()()
-{
-    bool localThreadSwitch;
+    // *** MUST BE THREAD-SAFE ****
+    // This method will be called by multiple threads simultaneously
+    // Main thread entry point.
+    // _threadSwitch flips on each call; this makes alternate threads run _doEnqueues() and _doDequeues()
+    void
+    JournalInstance::operator()()
     {
-        std::lock_guard<std::mutex> l(_ts_lock);
-        localThreadSwitch = _threadSwitch;
-        _threadSwitch = !_threadSwitch;
+        bool localThreadSwitch; // thread local
+        { // --- START OF CRITICAL SECTION ---
+            std::lock_guard<std::mutex> l(_threadSwitchLock);
+            localThreadSwitch = _threadSwitch;
+            _threadSwitch = !_threadSwitch;
+        } // --- END OF CRITICAL SECTION ---
+        if (localThreadSwitch) {
+            _doDequeues();
+        } else {
+            _doEnqueues();
+        }
     }
-    if (localThreadSwitch) {
-        _doDequeues();
-    } else {
-        _doEnqueues();
-    }
-}
 
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-void
+    // *** MUST BE THREAD-SAFE ****
+    // This method will be called by multiple threads simultaneously
+    void
 #ifdef JOURNAL2
-JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
-{
-    mrg::journal2::dtok* dtokPtr;
+    JournalInstance::wr_aio_cb(std::vector<mrg::journal2::dtok*>& dataTokenList)
+    {
+        mrg::journal2::dtok* dtokPtr;
 #else
-JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
-{
-    mrg::journal::data_tok* dtokPtr;
-#endif
-    while (dataTokenList.size())
+    JournalInstance::wr_aio_cb(std::vector<mrg::journal::data_tok*>& dataTokenList)
     {
-        dtokPtr = dataTokenList.back();
-        dataTokenList.pop_back();
-#ifdef JOURNAL2
-        switch (dtokPtr->get_dtok_state().get_op_state())
+        mrg::journal::data_tok* dtokPtr;
+#endif
+        while (dataTokenList.size())
         {
-        case mrg::journal2::OP_ENQUEUE:
+            dtokPtr = dataTokenList.back();
+            dataTokenList.pop_back();
+#ifdef JOURNAL2
+            switch (dtokPtr->get_dtok_state().get_op_state()) {
+                case mrg::journal2::OP_ENQUEUE:
 
 #else
-        switch (dtokPtr->wstate())
-        {
-        case mrg::journal::data_tok::ENQ:
+            switch (dtokPtr->wstate()) {
+                case mrg::journal::data_tok::ENQ:
 #endif
-            {
-                std::unique_lock<std::mutex> l(_unprocCallbackListMutex);
-                _unprocCallbackList.push(dtokPtr);
+                    { // --- START OF CRITICAL SECTION ---
+                        std::lock_guard<std::mutex> l(_unprocCallbackListMutex);
+                        _unprocCallbackList.push(dtokPtr);
+                    } // --- END OF CRITICAL SECTION ---
+                break;
+            default:
+                delete dtokPtr;
             }
-            break;
-        default:
-            delete dtokPtr;
         }
     }
-}
 
-// *** MUST BE THREAD-SAFE ****
-// This method will be called by multiple threads simultaneously
-void
-JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
-{}
+    // *** MUST BE THREAD-SAFE ****
+    // This method will be called by multiple threads simultaneously
+    void
+    JournalInstance::rd_aio_cb(std::vector<uint16_t>& /*buffPageCtrlBlkIndexList*/)
+    {}
 
 } // namespace jtest
 } // namespace mrg

Modified: store/trunk/cpp/perf/JournalInstance.hpp
===================================================================
--- store/trunk/cpp/perf/JournalInstance.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalInstance.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -76,7 +76,7 @@
 #endif
         std::mutex _unprocCallbackListMutex;    ///< Mutex which protects the unprocessed callback queue
         bool _threadSwitch;                     ///< A switch which alternates worker threads between enq and deq
-        std::mutex _ts_lock;                    ///< Mutex which protects the thread switch
+        std::mutex _threadSwitchLock;           ///< Mutex which protects the thread switch
 
         /**
          * \brief Worker thread enqueue task
@@ -105,8 +105,6 @@
         /**
          * \brief Constructor
          *
-         * Constructor.
-         *
          * \param numMsgs Number of messages per thread to be enqueued then dequeued (ie both ways through broker)
          * \param msgSize Size of each message being enqueued
          * \param msgData Pointer to message content (all messages have identical content)
@@ -125,9 +123,7 @@
 #endif
 
         /**
-         * \brief Destructor
-         *
-         * Destructor.
+         * \brief virtual destructor
          */
         virtual ~JournalInstance();
 

Modified: store/trunk/cpp/perf/JournalParameters.cpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalParameters.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -31,85 +31,78 @@
 
 #include "JournalParameters.hpp"
 
-#include <sstream>
-
 namespace mrg
 {
 namespace jtest
 {
 
-// static declarations
-std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
-std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
-uint16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
-uint32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
-bool JournalParameters::_s_defaultAutoExpand = false;
-uint16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
-uint16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
-uint32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
+    // static declarations
+    std::string JournalParameters::_s_defaultJrnlDir = "/tmp/store";
+    std::string JournalParameters::_s_defaultJrnlBaseFileName = "JournalData";
+    uint16_t JournalParameters::_s_defaultNumJrnlFiles = 8;
+    uint32_t JournalParameters::_s_defaultJrnlFileSize_sblks = 3072;
+    bool JournalParameters::_s_defaultAutoExpand = false;
+    uint16_t JournalParameters::_s_defaultAutoExpandMaxJrnlFiles = 0;
+    uint16_t JournalParameters::_s_defaultWriteBuffNumPgs = 32;
+    uint32_t JournalParameters::_s_defaultWriteBuffPgSize_sblks = 128;
 
-JournalParameters::JournalParameters() :
-                                     _jrnlDir(_s_defaultJrnlDir),
-                                     _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
-                                     _numJrnlFiles(_s_defaultNumJrnlFiles),
-                                     _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
-                                     _autoExpand(_s_defaultAutoExpand),
-                                     _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
-                                     _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
-                                     _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
-{}
+    JournalParameters::JournalParameters() :
+                                         Streamable(),
+                                         _jrnlDir(_s_defaultJrnlDir),
+                                         _jrnlBaseFileName(_s_defaultJrnlBaseFileName),
+                                         _numJrnlFiles(_s_defaultNumJrnlFiles),
+                                         _jrnlFileSize_sblks(_s_defaultJrnlFileSize_sblks),
+                                         _autoExpand(_s_defaultAutoExpand),
+                                         _autoExpandMaxJrnlFiles(_s_defaultAutoExpandMaxJrnlFiles),
+                                         _writeBuffNumPgs(_s_defaultWriteBuffNumPgs),
+                                         _writeBuffPgSize_sblks(_s_defaultWriteBuffPgSize_sblks)
+    {}
 
-JournalParameters::JournalParameters(const std::string& jrnlDir,
-                                     const std::string& jrnlBaseFileName,
-                                     const uint16_t numJrnlFiles,
-                                     const uint32_t jrnlFileSize_sblks,
-                                     const bool autoExpand,
-                                     const uint16_t autoExpandMaxJrnlFiles,
-                                     const uint16_t writeBuffNumPgs,
-                                     const uint32_t writeBuffPgSize_sblks) :
-                                     _jrnlDir(jrnlDir),
-                                     _jrnlBaseFileName(jrnlBaseFileName),
-                                     _numJrnlFiles(numJrnlFiles),
-                                     _jrnlFileSize_sblks(jrnlFileSize_sblks),
-                                     _autoExpand(autoExpand),
-                                     _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
-                                     _writeBuffNumPgs(writeBuffNumPgs),
-                                     _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
-{}
+    JournalParameters::JournalParameters(const std::string& jrnlDir,
+                                         const std::string& jrnlBaseFileName,
+                                         const uint16_t numJrnlFiles,
+                                         const uint32_t jrnlFileSize_sblks,
+                                         const bool autoExpand,
+                                         const uint16_t autoExpandMaxJrnlFiles,
+                                         const uint16_t writeBuffNumPgs,
+                                         const uint32_t writeBuffPgSize_sblks) :
+                                         Streamable(),
+                                         _jrnlDir(jrnlDir),
+                                         _jrnlBaseFileName(jrnlBaseFileName),
+                                         _numJrnlFiles(numJrnlFiles),
+                                         _jrnlFileSize_sblks(jrnlFileSize_sblks),
+                                         _autoExpand(autoExpand),
+                                         _autoExpandMaxJrnlFiles(autoExpandMaxJrnlFiles),
+                                         _writeBuffNumPgs(writeBuffNumPgs),
+                                         _writeBuffPgSize_sblks(writeBuffPgSize_sblks)
+    {}
 
-JournalParameters::JournalParameters(const JournalParameters& jp) :
-                                     _jrnlDir(jp._jrnlDir),
-                                     _jrnlBaseFileName(jp._jrnlBaseFileName),
-                                     _numJrnlFiles(jp._numJrnlFiles),
-                                     _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
-                                     _autoExpand(jp._autoExpand),
-                                     _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
-                                     _writeBuffNumPgs(jp._writeBuffNumPgs),
-                                     _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
+    JournalParameters::JournalParameters(const JournalParameters& jp) :
+                                         Streamable(),
+                                         _jrnlDir(jp._jrnlDir),
+                                         _jrnlBaseFileName(jp._jrnlBaseFileName),
+                                         _numJrnlFiles(jp._numJrnlFiles),
+                                         _jrnlFileSize_sblks(jp._jrnlFileSize_sblks),
+                                         _autoExpand(jp._autoExpand),
+                                         _autoExpandMaxJrnlFiles(jp._autoExpandMaxJrnlFiles),
+                                         _writeBuffNumPgs(jp._writeBuffNumPgs),
+                                         _writeBuffPgSize_sblks(jp._writeBuffPgSize_sblks)
 
-{}
+    {}
 
-void
-JournalParameters::toStream(std::ostream& os)
-{
-    os << "Store Parameters:" << std::endl;
-    os << "  jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
-    os << "  jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
-    os << "  numJrnlFiles = " << _numJrnlFiles << std::endl;
-    os << "  jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
-    os << "  autoExpand = " << _autoExpand << std::endl;
-    os << "  autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
-    os << "  writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
-    os << "  writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
-}
+    void
+    JournalParameters::toStream(std::ostream& os) const
+    {
+        os << "Store Parameters:" << std::endl;
+        os << "  jrnlDir = \"" << _jrnlDir << "\"" << std::endl;
+        os << "  jrnlBaseFileName = \"" << _jrnlBaseFileName << "\"" << std::endl;
+        os << "  numJrnlFiles = " << _numJrnlFiles << std::endl;
+        os << "  jrnlFileSize_sblks = " << _jrnlFileSize_sblks << std::endl;
+        os << "  autoExpand = " << _autoExpand << std::endl;
+        os << "  autoExpandMaxJrnlFiles = " << _autoExpandMaxJrnlFiles << std::endl;
+        os << "  writeBuffNumPgs = " << _writeBuffNumPgs << std::endl;
+        os << "  writeBuffPgSize_sblks = " << _writeBuffPgSize_sblks << std::endl;
+    }
 
-std::string
-JournalParameters::toString()
-{
-    std::ostringstream oss;
-    toStream(oss);
-    return oss.str();
-}
-
 } // namespace jtest
 } // namespace mrg

Modified: store/trunk/cpp/perf/JournalParameters.hpp
===================================================================
--- store/trunk/cpp/perf/JournalParameters.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/JournalParameters.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -33,8 +33,7 @@
 #define mrg_jtest_JournalParameters_hpp
 
 #include <cstdint>
-#include <iostream>
-#include <string>
+#include "Streamable.hpp"
 
 namespace mrg
 {
@@ -47,7 +46,7 @@
      * This struct is used to aggregate and keep together all the common journal parameters. These affect the journal
      * geometry and buffers. The test parameters are aggregated in class TestParameters.
      */
-    struct JournalParameters
+    struct JournalParameters : public Streamable
     {
         // static default store params
         static std::string _s_defaultJrnlDir;               ///< Default journal directory
@@ -101,12 +100,15 @@
         /**
          * \brief Copy constructor
          *
-         * Copy constructor.
-         *
          * \param jp Reference to JournalParameters instance to be copied
          */
         JournalParameters(const JournalParameters& jp);
 
+        /**
+         * \brief Virtual destructor
+         */
+        virtual ~JournalParameters() {}
+
         /***
          * \brief Stream the journal parameters to an output stream
          *
@@ -115,17 +117,7 @@
          *
          * \param os Output stream to which the class data is to be streamed
          */
-        void toStream(std::ostream& os = std::cout);
-
-        /**
-         * \brief Creates a string representation of the journal parameters
-         *
-         * Convenience feature which creates a multi-line string representation of all the journal parameters, one per
-         * line.
-         *
-         * \return multi-line string representation of all the parameters, one parameter per line.
-         */
-        std::string toString();
+        void toStream(std::ostream& os = std::cout) const;
     };
 
 } // namespace jtest

Copied: store/trunk/cpp/perf/JournalPerformanceTest.cpp (from rev 4428, store/trunk/cpp/perf/StorePerformanceTest.cpp)
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.cpp	                        (rev 0)
+++ store/trunk/cpp/perf/JournalPerformanceTest.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,312 @@
+/**
+ * \file JournalPerformanceTest.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "JournalPerformanceTest.hpp"
+
+#include <cstdint> // uint16_t, uint32_t
+#include <cstdlib> // atof, atoi, atol
+#include <deque>
+#include <getopt.h> // getopt_long(), required_argument, no_argument
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <thread>
+
+#include "ScopedTimer.hpp"
+#ifdef JOURNAL2
+#include "jrnl2/jdir.hpp"
+#else
+#include "jrnl/jdir.hpp"
+#endif
+
+namespace mrg
+{
+namespace jtest
+{
+
+#ifdef JOURNAL2
+    JournalPerformanceTest::JournalPerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp) :
+#else
+    JournalPerformanceTest::JournalPerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
+#endif
+                                                   Streamable(),
+                                                   _testParams(tp),
+                                                   _jrnlParams(jp),
+                                                   _jrnlPerf(tp),
+                                                   msgData(new char[tp._msgSize])
+    {}
+
+    JournalPerformanceTest::~JournalPerformanceTest()
+    {
+        while (_jrnlList.size()) {
+            delete _jrnlList.back();
+            _jrnlList.pop_back();
+        }
+        delete[] msgData;
+    }
+
+    void
+    JournalPerformanceTest::_prepareJournals()
+    {
+#ifdef JOURNAL2
+        if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
+            mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
+        }
+        mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
+        mrg::journal2::jrnl* jp;
+#else
+        if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
+            mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
+        }
+        mrg::journal::jdir::create_dir(_jrnlParams._jrnlDir);
+        mrg::journal::jcntl* jp;
+#endif
+        JournalInstance* ptp;
+        for (uint16_t j = 0; j < _testParams._numQueues; j++) {
+            std::ostringstream jname;
+            jname << "jrnl_" << std::setw(4) << std::setfill('0') << j;
+            std::ostringstream jdir;
+            jdir << _jrnlParams._jrnlDir << "/" << jname.str();
+#ifdef JOURNAL2
+            jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
+#else
+            jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
+#endif
+            ptp = new JournalInstance(_testParams._numMsgs, _testParams._msgSize, msgData, jp);
+#ifdef JOURNAL2
+            jp->initialize(&_jrnlParams, ptp);
+#else
+            jp->initialize(_jrnlParams._numJrnlFiles, _jrnlParams._autoExpand, _jrnlParams._autoExpandMaxJrnlFiles,
+                        _jrnlParams._jrnlFileSize_sblks, _jrnlParams._writeBuffNumPgs,
+                        _jrnlParams._writeBuffPgSize_sblks, ptp);
+#endif
+
+            _jrnlList.push_back(ptp);
+        }
+    }
+
+    void
+    JournalPerformanceTest::run()
+    {
+        std::deque<std::thread*> threads;
+        std::thread* tp;
+        _prepareJournals();
+        { // --- Start of timed section ---
+            ScopedTimer st(_jrnlPerf);
+
+            for (uint16_t q = 0; q < _testParams._numQueues; q++) {
+                // Launch threads in pairs
+                uint16_t numThreads = _testParams._numThreadPairsPerQueue * 2;
+                for (uint16_t t = 0; t < numThreads; t++) {
+                    tp = new std::thread(std::ref(*_jrnlList[q]));
+                    threads.push_back(tp);
+                }
+            }
+
+            while (threads.size()) {
+                threads.front()->join();
+                delete threads.front();
+                threads.pop_front();
+            }
+        } // --- End of timed section ---
+    }
+
+    void
+    JournalPerformanceTest::toStream(std::ostream& os) const
+    {
+        os << _testParams << std::endl;
+        os << _jrnlParams << std::endl;
+        os << _jrnlPerf << std::endl;
+    }
+
+    void
+    printArgs(std::ostream& os)
+    {
+        os << " -h --help:                       This help message" << std::endl;
+        os << std::endl;
+        os << "Test params:" << std::endl;
+        os << " -M --num_msgs:                   Number of messages to send ["
+           << TestParameters::_s_defaultNumMsgs << "]" << std::endl;
+        os << " -S --msg_size:                   Size of each message to be sent ["
+           << TestParameters::_s_defaultMsgSize << "]" << std::endl;
+        os << " -Q --num_queues:                 Number of simultaneous queues ["
+           << TestParameters::_s_defaultNumQueues << "]" << std::endl;
+        os << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
+           << TestParameters::_s_defaultNumThreadPairsPerQueue << "]" << std::endl;
+        os << " -E --enq_txn_blk_size:           Enqueue transaction block size (0=non-txn) ["
+           << TestParameters::_s_defaultEnqTxnBlkSize << "]" << std::endl;
+        os << " -D --deq_txn_blk_size:           Dequeue transaction block size (0=non-txn) ["
+           << TestParameters::_s_defaultDeqTxnBlkSize << "]" << std::endl;
+        os << std::endl;
+        os << "Store params:" << std::endl;
+#ifdef JOURNAL2
+        os << " -d --jrnl_dir:                   Store directory [\""
+           << mrg::journal2::JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
+        os << " -b --jrnl_base_filename:         Base name for journal files [\""
+           << mrg::journal2::JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
+        os << " -f --num_jfiles:                 Number of journal files ["
+           << mrg::journal2::JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
+        os << " -s --jfsize_sblks:               Size of each journal file in sblks (512 byte blocks) ["
+           << mrg::journal2::JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
+        os << " -a --auto_expand:                Auto-expand the journal ["
+           << (mrg::journal2::JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
+        os << " -e --ae_max_jfiles:              Upper limit on number of auto-expanded journal files ["
+           << mrg::journal2::JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
+        os << " -p --wcache_num_pages:           Number of write buffer pages ["
+           << mrg::journal2::JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
+        os << " -c --wcache_pgsize_sblks:        Size of each write buffer page in sblks (512 byte blocks) ["
+           << mrg::journal2::JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
+#else
+        os << " -d --jrnl_dir:                   Store directory [\""
+           << JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
+        os << " -b --jrnl_base_filename:         Base name for journal files [\""
+           << JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
+        os << " -f --num_jfiles:                 Number of journal files ["
+           << JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
+        os << " -s --jfsize_sblks:               Size of each journal file in sblks (512 byte blocks) ["
+           << JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
+        os << " -a --auto_expand:                Auto-expand the journal ["
+           << (JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
+        os << " -e --ae_max_jfiles:              Upper limit on number of auto-expanded journal files ["
+           << JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
+        os << " -p --wcache_num_pages:           Number of write buffer pages ["
+           << JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
+        os << " -c --wcache_pgsize_sblks:        Size of each write buffer page in sblks (512 byte blocks) ["
+           << JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
+#endif
+}
+
+    bool
+#ifdef JOURNAL2
+    readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& sp)
+#else
+    readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& sp)
+#endif
+    {
+        static struct option long_options[] = {
+            {"help", no_argument, 0, 'h'},
+
+            // Test params
+            {"num_msgs", required_argument, 0, 'm'},
+            {"msg_size", required_argument, 0, 'S'},
+            {"num_queues", required_argument, 0, 'q'},
+            {"num_threads_per_queue", required_argument, 0, 't'},
+
+            // Journal params
+            {"jrnl_dir", required_argument, 0, 'd'},
+            {"jrnl_base_filename", required_argument, 0, 'b'},
+            {"num_jfiles", required_argument, 0, 'f'},
+            {"jfsize_sblks", required_argument, 0, 's'},
+            {"auto_expand", no_argument, 0, 'a'},
+            {"ae_max_jfiles", required_argument, 0, 'e'},
+            {"wcache_num_pages", required_argument, 0, 'p'},
+            {"wcache_pgsize_sblks", required_argument, 0, 'c'},
+
+            {0, 0, 0, 0}
+        };
+
+        bool err = false;
+        int c = 0;
+        while (true) {
+            int option_index = 0;
+            c = getopt_long(argc, argv, "ab:c:d:e:f:hm:p:q:s:S:t:", long_options, &option_index);
+            if (c == -1) break;
+            switch (c) {
+                // Test params
+                case 'm':
+                    tp._numMsgs = uint32_t(std::atol(optarg));
+                    break;
+                case 'S':
+                    tp._msgSize = uint32_t(std::atol(optarg));
+                    break;
+                case 'q':
+                    tp._numQueues = uint16_t(std::atoi(optarg));
+                    break;
+                case 't':
+                    tp._numThreadPairsPerQueue = uint16_t(std::atoi(optarg));
+                    break;
+
+                // Store params
+                case 'd':
+                    sp._jrnlDir.assign(optarg);
+                    break;
+                case 'b':
+                    sp._jrnlBaseFileName.assign(optarg);
+                    break;
+                case 'f':
+                    sp._numJrnlFiles = uint16_t(std::atoi(optarg));
+                    break;
+                case 's':
+                    sp._jrnlFileSize_sblks = uint32_t(std::atol(optarg));
+                    break;
+                case 'a':
+                    sp._autoExpand = true;
+                    break;
+                case 'e':
+                    sp._autoExpandMaxJrnlFiles = uint16_t(std::atoi(optarg));
+                    break;
+                case 'p':
+                    sp._writeBuffNumPgs = uint16_t(std::atoi(optarg));
+                    break;
+                case 'c':
+                    sp._writeBuffPgSize_sblks = uint32_t(std::atol(optarg));
+                    break;
+
+                // Other
+                case 'h':
+                default:
+                    err = true;
+                    printArgs();
+            }
+        }
+        return err;
+    }
+
+} // namespace jtest
+} // namespace mrg
+
+// -----------------------------------------------------------------
+
+int
+main(int argc, char** argv)
+{
+    mrg::jtest::TestParameters tp;
+#ifdef JOURNAL2
+    mrg::journal2::JournalParameters jp;
+#else
+    mrg::jtest::JournalParameters jp;
+#endif
+    if (mrg::jtest::readArgs(argc, argv, tp, jp)) return 1;
+    mrg::jtest::JournalPerformanceTest jpt(tp, jp);
+    jpt.run();
+    std::cout << jpt << std::endl;
+    return 0;
+}

Copied: store/trunk/cpp/perf/JournalPerformanceTest.hpp (from rev 4428, store/trunk/cpp/perf/StorePerformanceTest.hpp)
===================================================================
--- store/trunk/cpp/perf/JournalPerformanceTest.hpp	                        (rev 0)
+++ store/trunk/cpp/perf/JournalPerformanceTest.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,147 @@
+/**
+ * \file JournalPerformanceTest.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_JournalPerformanceTest_hpp
+#define mrg_jtest_JournalPerformanceTest_hpp
+
+#include <vector>
+
+#include "JournalInstance.hpp"
+#include "PerformanceResult.hpp"
+#include "Streamable.hpp"
+#include "TestParameters.hpp"
+
+#ifdef JOURNAL2
+#include "jrnl2/JournalParameters.hpp"
+#else
+#include "JournalParameters.hpp"
+#endif
+
+
+
+namespace mrg
+{
+namespace jtest
+{
+
+    /**
+     * \brief Main test class; Create an instance and execute run()
+     *
+     * Main test class which aggregates the components of a test.
+     */
+    class JournalPerformanceTest : public Streamable
+    {
+        const TestParameters& _testParams;          ///< Ref to a struct containing test params
+#ifdef JOURNAL2
+        const mrg::journal2::JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
+#else
+        const JournalParameters& _jrnlParams;       ///< Ref to a struct containing the journal parameters
+#endif
+        PerformanceResult _jrnlPerf;               ///< Journal performance object
+        const char* msgData;                        ///< Pointer to msg data, which is the same for all messages
+        std::vector<JournalInstance*> _jrnlList;    ///< List of journals (JournalInstance instances) being tested
+
+        /**
+         * \brief Creates journals and JournalInstance classes for all journals (queues) to be tested
+         *
+         * Creates a new journal instance and JournalInstance instance for each queue. The journals are initialized
+         * which creates a new set of journal files on the local storage media (which is determined by path in
+         * JournalParameters._jrnlDir). This activity is not timed, and is not a part of the performance test per se.
+         */
+        void _prepareJournals();
+
+    public:
+        /**
+         * \brief Constructor
+         *
+         * \param tp Test parameters for the test
+         * \param jp Journal parameters for all queues (journals) in the test
+         */
+#ifdef JOURNAL2
+        JournalPerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp);
+#else
+        JournalPerformanceTest(const TestParameters& tp, const JournalParameters& jp);
+#endif
+
+        /**
+         * \brief Virtual destructor
+         */
+        virtual ~JournalPerformanceTest();
+
+        /**
+         * \brief Runs the test and prints out the results.
+         *
+         * Runs the test  as set by the test parameters and journal parameters.
+         */
+        void run();
+
+        /**
+         * \brief Stream the test setup and results to an output stream
+         *
+         * Convenience feature which streams the test setup and results to an output stream.
+         *
+         * \param os Output stream to which the test setup and results are to be streamed.
+         */
+        void toStream(std::ostream& os = std::cout) const;
+    };
+
+    /**
+     * \brief Print out the program arguments
+     *
+     * Print out the arguments to the performance program if requested by help or a parameter error.
+     *
+     * \param os Stream to which the arguments should be streamed.
+     */
+    void printArgs(std::ostream& os = std::cout);
+
+    /**
+     * \brief Process the command-line arguments
+     *
+     * Process the command-line arguments and populate the TestParameters and JournalParameters structs. Only the
+     * arguments supplied are on the command-line are changed in these structs, the others remain unchanged. It is
+     * important therefore to make sure that defaults are pre-loaded (the default behavior of the default constructors
+     * for these structs).
+     *
+     * \param argc Number of command-line arguments.  Process directly from main().
+     * \param argv Pointer to array of command-line argument pointers. Process directly from main().
+     * \param tp Reference to test parameter object. Only params on the command-line are changed.
+     * \param jp Reference to journal parameter object. Only params on the command-line are changed.
+     */
+#ifdef JOURNAL2
+    bool readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& jp);
+#else
+    bool readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& jp);
+#endif
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_JournalPerformanceTest_hpp

Modified: store/trunk/cpp/perf/Makefile.am
===================================================================
--- store/trunk/cpp/perf/Makefile.am	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/Makefile.am	2010-12-08 16:26:09 UTC (rev 4430)
@@ -30,13 +30,18 @@
 perf_SOURCES = \
   JournalInstance.cpp \
   JournalParameters.cpp \
-  ScopedPerformanceTimer.cpp \
-  StorePerformanceTest.cpp \
+  JournalPerformanceTest.cpp \
+  PerformanceResult.cpp \
+  ScopedTimer.cpp \
+  Streamable.cpp \
   TestParameters.cpp \
   JournalInstance.hpp \
   JournalParameters.hpp \
-  ScopedPerformanceTimer.hpp \
-  StorePerformanceTest.hpp \
+  JournalPerformanceTest.hpp \
+  PerformanceResult.hpp \
+  ScopedTimable.hpp \
+  ScopedTimer.hpp \
+  Streamable.hpp \
   TestParameters.hpp
 perf_CXXFLAGS = -std=c++0x -lpthread
 perf_LDADD  = -lrt $(top_builddir)/lib/msgstore.la

Copied: store/trunk/cpp/perf/PerformanceResult.cpp (from rev 4428, store/trunk/cpp/perf/ScopedPerformanceTimer.cpp)
===================================================================
--- store/trunk/cpp/perf/PerformanceResult.cpp	                        (rev 0)
+++ store/trunk/cpp/perf/PerformanceResult.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file PerformanceResult.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "PerformanceResult.hpp"
+
+#include <cstdint> // uint32_t
+
+namespace mrg
+{
+namespace jtest
+{
+
+    PerformanceResult::PerformanceResult(const TestParameters& tp) :
+                                         ScopedTimable(),
+                                         Streamable(),
+                                         _testParams(tp)
+    {}
+
+    void
+    PerformanceResult::toStream(std::ostream& os) const
+    {
+        os << "TEST RESULTS:" << std::endl;
+        os << "    Msgs per thread: " << _testParams._numMsgs << std::endl;
+        os << "           Msg size: " << _testParams._msgSize << std::endl;
+        os << "         No. queues: " << _testParams._numQueues << std::endl;
+        os << "  No. threads/queue: " << _testParams._numThreadPairsPerQueue << std::endl;
+        os << "         Time taken: " << _elapsed << " sec" << std::endl;
+        uint32_t totalMsgs = _testParams._numMsgs * _testParams._numQueues * _testParams._numThreadPairsPerQueue;
+        os << "     Total no. msgs: " << totalMsgs << std::endl;
+        double msgsRate = double(totalMsgs) / _elapsed;
+        os << "     Msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
+        os << "                     " << (msgsRate * _testParams._msgSize / 1e6) << " MB/sec" << std::endl;
+    }
+
+} // namespace jtest
+} // namespace mrg

Copied: store/trunk/cpp/perf/PerformanceResult.hpp (from rev 4428, store/trunk/cpp/perf/ScopedPerformanceTimer.hpp)
===================================================================
--- store/trunk/cpp/perf/PerformanceResult.hpp	                        (rev 0)
+++ store/trunk/cpp/perf/PerformanceResult.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,101 @@
+/**
+ * \file PerformanceResult.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_PerformanceResult_hpp
+#define mrg_jtest_PerformanceResult_hpp
+
+#include <iostream>
+
+#include "TestParameters.hpp"
+#include "ScopedTimable.hpp"
+#include "Streamable.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+    /**
+     * \brief Results class that accepts an elapsed time to calculate the rate of message throughput in the journal.
+     *
+     * This class (being subclassed from ScopedTimable) is passed to a ScopedTimer object on construction, and the
+     * inherited _elapsed member will be written with the calculated elapsed time (in seconds) on destruction of the
+     * ScopedTimer object. This time (initially set to 0.0) is used to calculate message and message byte throughput.
+     * The message number and size information comes from the TestParameters object passed to the constructor.
+     *
+     * Results are available through the use of toStream(), toString() or the << operators.
+     *
+     * Output is in the following format:
+     * <pre>
+     * TEST RESULTS:
+     *     Msgs per thread: 10000
+     *            Msg size: 2048
+     *          No. queues: 2
+     *   No. threads/queue: 2
+     *          Time taken: 1.6626 sec
+     *      Total no. msgs: 40000
+     *      Msg throughput: 24.0587 kMsgs/sec
+     *                      49.2723 MB/sec
+     * </pre>
+     */
+    class PerformanceResult : public ScopedTimable, public Streamable
+    {
+        TestParameters _testParams; ///< Test parameters used for performance calculations
+
+    public:
+        /**
+         * \brief Constructor
+         *
+         * Constructor. Will start the time interval measurement.
+         *
+         * \param tp Test parameter details used to calculate the performance results.
+         */
+        PerformanceResult(const TestParameters& tp);
+
+        /**
+         * \brief Virtual destructor
+         */
+        virtual ~PerformanceResult() {}
+
+        /**
+         * \brief Stream the performance test results to an output stream
+         *
+         * Convenience feature which streams a multi-line performance result an output stream.
+         *
+         * \param os Output stream to which the results are to be streamed
+         */
+        void toStream(std::ostream& os = std::cout) const;
+    };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_PerformanceResult_hpp

Deleted: store/trunk/cpp/perf/ScopedPerformanceTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,72 +0,0 @@
-/**
- * \file ScopedPerformanceTimer.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- * USA
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "ScopedPerformanceTimer.hpp"
-
-namespace mrg
-{
-namespace jtest
-{
-    ScopedPerformanceTimer::ScopedPerformanceTimer(const TestParameters& tp,
-                                                   std::ostream& os) :
-                                                   _testParams(tp),
-                                                   _outStream(os)
-    {
-        ::clock_gettime(CLOCK_REALTIME, &_startTime);
-    }
-
-    ScopedPerformanceTimer::~ScopedPerformanceTimer()
-    {
-        ::timespec stopTime;
-        ::clock_gettime(CLOCK_REALTIME, &stopTime);
-        double timeTaken = _s_getDoubleTime(stopTime) - _s_getDoubleTime(_startTime);
-        _outStream << "TEST RESULTS:" << std::endl;
-        _outStream << "    Msgs per thread: " << _testParams._numMsgs << std::endl;
-        _outStream << "           Msg size: " << _testParams._msgSize << std::endl;
-        _outStream << "         No. queues: " << _testParams._numQueues << std::endl;
-        _outStream << "  No. threads/queue: " << _testParams._numThreadPairsPerQueue << std::endl;
-        _outStream << "         Time taken: " << timeTaken << " sec" << std::endl;
-        uint32_t msgs = _testParams._numMsgs * _testParams._numQueues * _testParams._numThreadPairsPerQueue;
-        _outStream << "     Total no. msgs: " << msgs << std::endl;
-        double msgsRate = double(msgs) / timeTaken;
-        _outStream << "     Msg throughput: " << (msgsRate / 1e3) << " kMsgs/sec" << std::endl;
-        _outStream << "                     " << (msgsRate * _testParams._msgSize / 1e6) << " MB/sec" << std::endl;
-    }
-
-    // static
-    double ScopedPerformanceTimer::_s_getDoubleTime(const ::timespec& ts)
-    {
-        return ts.tv_sec + (double(ts.tv_nsec) / 1e9);
-    }
-
-
-} // namespace jtest
-} // namespace mrg

Deleted: store/trunk/cpp/perf/ScopedPerformanceTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedPerformanceTimer.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/ScopedPerformanceTimer.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,106 +0,0 @@
-/**
- * \file ScopedPerformanceTimer.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- * USA
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_jtest_ScopedPerformanceTimer_hpp
-#define mrg_jtest_ScopedPerformanceTimer_hpp
-
-#include <cstdint>
-#include <ctime>
-#include <iostream>
-
-#include "TestParameters.hpp"
-
-namespace mrg
-{
-namespace jtest
-{
-
-    /**
-     * \brief Scoped timer class that starts timing on construction and finishes on destruction.
-     *
-     * This simple scoped timer class will record the start time on construction. On destruction (going out of scope),
-     * it will record the stop time, and will then print out the elapsed time and some simple performance numbers.
-     * The performance calculations are made from the data in the supplied TestParameters struct.
-     *
-     * Output is in the following format:
-     * <pre>
-     * TEST RESULTS:
-     *     Msgs per thread: 10000
-     *            Msg size: 2048
-     *          No. queues: 2
-     *   No. threads/queue: 2
-     *          Time taken: 1.6626 sec
-     *      Total no. msgs: 40000
-     *      Msg throughput: 24.0587 kMsgs/sec
-     *                      49.2723 MB/sec
-     * </pre>
-     */
-    class ScopedPerformanceTimer
-    {
-    protected:
-        TestParameters _testParams; ///< Test parameters used for performance calculations
-        std::ostream& _outStream;   ///< Output stream for the performance data sent at destruction
-        ::timespec  _startTime;     ///< Start time, set on construction
-
-        /**
-         * \brief Convert ::timespec to seconds
-         *
-         * Static function to convert a ::timespec struct into a double representation in seconds.
-         *
-         * \param ts ::timespec struct containing the time to be converted.
-         * \return A double which represents the time in parameter ts in seconds.
-         */
-        static double _s_getDoubleTime(const ::timespec& ts);
-    public:
-        /**
-         * \brief Constructor
-         *
-         * Constructor. Will start the time interval measurement.
-         *
-         * \param tp Test parameter details used to calculate the performance results.
-         * \param os Output stream to which the results will be sent on destruction.
-         */
-        ScopedPerformanceTimer(const TestParameters& tp,
-                               std::ostream& os = std::cout);
-
-        /**
-         * \brief Destructor
-         *
-         * Destructor. Will stop the time interval measurement and send the performance results to the out stream
-         * object _outStream.
-         */
-        ~ScopedPerformanceTimer();
-    };
-
-} // namespace jtest
-} // namespace mrg
-
-#endif // mrg_jtest_ScopedPerformanceTimer_hpp

Added: store/trunk/cpp/perf/ScopedTimable.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimable.hpp	                        (rev 0)
+++ store/trunk/cpp/perf/ScopedTimable.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,81 @@
+/**
+ * \file ScopedTimable.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_ScopedTimable_hpp
+#define mrg_jtest_ScopedTimable_hpp
+
+namespace mrg
+{
+namespace jtest
+{
+
+    /**
+     * \brief Scoped timer class that starts timing on construction and finishes on destruction.
+     *
+     * This class is designed to be the parent class for a performance result class which depends on the elapsed
+     * time of some process or event. By passing this (or its subclasses) to ScopedTimer (which only exists within
+     * the scope of the event), the _elapsed member of this class will be written with the elapsed time when the
+     * ScopedTimer object goes out of scope or is destroyed.
+     *
+     * Subclasses may be aware of the parameters being timed, and may thus print and/or display performance and/or
+     * rate information for these parameters.
+     */
+    class ScopedTimable
+    {
+    protected:
+        double _elapsed;    ///< Elapsed time, will be written on destruction of ScopedTimer instances
+
+    public:
+        /**
+         * \brief Constructor
+         */
+        inline ScopedTimable() : _elapsed(0.0) {}
+
+        /**
+         * \brief Destructor
+         */
+        virtual inline ~ScopedTimable() {}
+
+        /**
+         * \brief Gets a ref to the elapsed time _elapsed.
+         *
+         * Returns a ref to the elapsed time _elapsed, for use in the constructor of ScopedTimer objects.
+         *
+         * \returns Ref to elapsed time _elapsed
+         */
+        // TODO: Investigate making this class a friend of ScopedTimer instead, exposing this as a public fn is ugly.
+        virtual inline double& getElapsedRef() { return _elapsed; }
+    };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_ScopedTimer_hpp

Added: store/trunk/cpp/perf/ScopedTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.cpp	                        (rev 0)
+++ store/trunk/cpp/perf/ScopedTimer.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file ScopedTimer.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "ScopedTimer.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+    ScopedTimer::ScopedTimer(double& elapsed) : _elapsed(elapsed)
+    {
+        ::clock_gettime(CLOCK_REALTIME, &_startTime);
+    }
+
+    ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st.getElapsedRef())
+    {
+        ::clock_gettime(CLOCK_REALTIME, &_startTime);
+    }
+
+    ScopedTimer::~ScopedTimer()
+    {
+        ::timespec stopTime;
+        ::clock_gettime(CLOCK_REALTIME, &stopTime);
+        _elapsed = _s_getDoubleTime(stopTime) - _s_getDoubleTime(_startTime);
+    }
+
+    // static
+    double ScopedTimer::_s_getDoubleTime(const ::timespec& ts)
+    {
+        return ts.tv_sec + (double(ts.tv_nsec) / 1e9);
+    }
+
+
+} // namespace jtest
+} // namespace mrg

Added: store/trunk/cpp/perf/ScopedTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.hpp	                        (rev 0)
+++ store/trunk/cpp/perf/ScopedTimer.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,99 @@
+/**
+ * \file ScopedTimer.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_ScopedTimer_hpp
+#define mrg_jtest_ScopedTimer_hpp
+
+#include <ctime>
+#include "ScopedTimable.hpp"
+
+namespace mrg
+{
+namespace jtest
+{
+
+    /**
+     * \brief Scoped timer class that starts timing on construction and finishes on destruction.
+     *
+     * The scoped timer will take the current time on construction and again on destruction. The destructor
+     * will calculate the elapsed time from the difference between these two times and write the result
+     * as a double to the double ref supplied to the constructor. A second constructor will accept a class (or
+     * subclass) of ScopedTimable, which contains a double to which the result may be written and accessed at a
+     * later time.
+     */
+    class ScopedTimer
+    {
+        double& _elapsed;           ///< Ref to elapsed time, will be written on destruction of ScopedTimer instances
+        ::timespec  _startTime;     ///< Start time, set on construction
+
+        /**
+         * \brief Convert ::timespec to seconds
+         *
+         * Static function to convert a ::timespec struct into a double representation in seconds.
+         *
+         * \param ts ::timespec struct containing the time to be converted.
+         * \return A double which represents the time in parameter ts in seconds.
+         */
+        static double _s_getDoubleTime(const ::timespec& ts);
+
+    public:
+        /**
+         * \brief Constructor
+         *
+         * Constructor which accepts a ref to a double. Will start the time interval measurement.
+         *
+         * \param elapsed A ref to a double which will contain the elapsed time in seconds after this class instance
+         *                is destroyed.
+         */
+        ScopedTimer(double& elapsed);
+
+        /**
+         * \brief Constructor
+         *
+         * Constructor which accepts a ref to a ScopedTimable. Will start the time interval measurement.
+         *
+         * \param st A ref to a ScopedTimable into which the result of the ScopedTimer can be written.
+         */
+        // TODO: Investigate making class ScopedTimer a friend of this class.
+        ScopedTimer(ScopedTimable& st);
+
+        /**
+         * \brief Destructor
+         *
+         * Destructor. Will stop the time interval measurement and write the calculated elapsed time into _elapsed.
+         */
+        ~ScopedTimer();
+    };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_ScopedTimer_hpp

Deleted: store/trunk/cpp/perf/StorePerformanceTest.cpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/StorePerformanceTest.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,316 +0,0 @@
-/**
- * \file StorePerformanceTest.cpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- * USA
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#include "StorePerformanceTest.hpp"
-
-#include <cstdint> // uint16_t, uint32_t
-#include <cstdlib> // atof, atoi, atol
-#include <deque>
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <thread>
-
-#include <getopt.h>
-#include <unistd.h>
-
-#include "ScopedPerformanceTimer.hpp"
-
-#ifdef JOURNAL2
-#include "jrnl2/jdir.hpp"
-#else
-#include "jrnl/jdir.hpp"
-#endif
-
-namespace mrg
-{
-namespace jtest
-{
-
-#ifdef JOURNAL2
-StorePerformanceTest::StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp) :
-#else
-StorePerformanceTest::StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp) :
-#endif
-           _testParams(tp),
-           _jrnlParams(jp),
-           msgData(new char[tp._msgSize])
-{}
-
-StorePerformanceTest::~StorePerformanceTest()
-{
-    while (_jrnlList.size())
-    {
-        delete _jrnlList.back();
-        _jrnlList.pop_back();
-    }
-    delete[] msgData;
-}
-
-void
-StorePerformanceTest::_prepareJournals()
-{
-#ifdef JOURNAL2
-    if (mrg::journal2::jdir::exists(_jrnlParams._jrnlDir)) {
-        mrg::journal2::jdir::delete_dir(_jrnlParams._jrnlDir);
-    }
-    mrg::journal2::jdir::create_dir(_jrnlParams._jrnlDir);
-    mrg::journal2::jrnl* jp;
-#else
-    if (mrg::journal::jdir::exists(_jrnlParams._jrnlDir)) {
-        mrg::journal::jdir::delete_dir(_jrnlParams._jrnlDir);
-    }
-    mrg::journal::jdir::create_dir(_jrnlParams._jrnlDir);
-    mrg::journal::jcntl* jp;
-#endif
-    JournalInstance* ptp;
-    for (uint16_t j = 0; j < _testParams._numQueues; j++)
-    {
-        std::ostringstream jname;
-        jname << "jrnl_" << std::setw(4) << std::setfill('0') << j;
-        std::ostringstream jdir;
-        jdir << _jrnlParams._jrnlDir << "/" << jname.str();
-#ifdef JOURNAL2
-        jp = new mrg::journal2::jrnl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
-#else
-        jp = new mrg::journal::jcntl(jname.str(), jdir.str(), _jrnlParams._jrnlBaseFileName);
-#endif
-        ptp = new JournalInstance(_testParams._numMsgs, _testParams._msgSize, msgData, jp);
-#ifdef JOURNAL2
-        jp->initialize(&_jrnlParams, ptp);
-#else
-        jp->initialize(_jrnlParams._numJrnlFiles, _jrnlParams._autoExpand, _jrnlParams._autoExpandMaxJrnlFiles,
-                        _jrnlParams._jrnlFileSize_sblks, _jrnlParams._writeBuffNumPgs,
-                        _jrnlParams._writeBuffPgSize_sblks, ptp);
-#endif
-
-        _jrnlList.push_back(ptp);
-    }
-}
-
-void
-StorePerformanceTest::run()
-{
-    std::deque<std::thread*> threads;
-    std::thread* tp;
-    _prepareJournals();
-    {
-        // --- Start of timed section ---
-        ScopedPerformanceTimer pt(_testParams);
-
-        for (uint16_t q=0; q<_testParams._numQueues; q++)
-        {
-            // Launch threads in pairs
-            for (uint16_t t=0; t<_testParams._numThreadPairsPerQueue * 2; t++)
-            {
-                tp = new std::thread(std::ref(*_jrnlList[q]));
-                threads.push_back(tp);
-            }
-        }
-
-        while (threads.size())
-        {
-            threads.front()->join();
-            delete threads.front();
-            threads.pop_front();
-        }
-        std::cout << std::endl;
-        // --- End of timed section ---
-    }
-}
-
-void
-printArgs(std::ostream& os)
-{
-    os << " -h --help:                       This help message" << std::endl;
-    os << std::endl;
-    os << "Test params:" << std::endl;
-    os << " -M --num_msgs:                   Number of messages to send ["
-              << TestParameters::_s_defaultNumMsgs << "]" << std::endl;
-    os << " -S --msg_size:                   Size of each message to be sent ["
-              << TestParameters::_s_defaultMsgSize << "]" << std::endl;
-    os << " -Q --num_queues:                 Number of simultaneous queues ["
-              << TestParameters::_s_defaultNumQueues << "]" << std::endl;
-    os << " -T --num_thread_pairs_per_queue: Number of thread pairs per queue ["
-              << TestParameters::_s_defaultNumThreadPairsPerQueue << "]" << std::endl;
-    os << " -E --enq_txn_blk_size:           Enqueue transaction block size (0=non-txn) ["
-              << TestParameters::_s_defaultEnqTxnBlkSize << "]" << std::endl;
-    os << " -D --deq_txn_blk_size:           Dequeue transaction block size (0=non-txn) ["
-              << TestParameters::_s_defaultDeqTxnBlkSize << "]" << std::endl;
-    os << std::endl;
-    os << "Store params:" << std::endl;
-#ifdef JOURNAL2
-    os << " -d --jrnl_dir:                   Store directory [\""
-              << mrg::journal2::JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
-    os << " -b --jrnl_base_filename:         Base name for journal files [\""
-              << mrg::journal2::JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
-    os << " -f --num_jfiles:                 Number of journal files ["
-              << mrg::journal2::JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
-    os << " -s --jfsize_sblks:               Size of each journal file in sblks (512 byte blocks) ["
-              << mrg::journal2::JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
-    os << " -a --auto_expand:                Auto-expand the journal ["
-              << (mrg::journal2::JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
-    os << " -e --ae_max_jfiles:              Upper limit on number of auto-expanded journal files ["
-              << mrg::journal2::JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
-    os << " -p --wcache_num_pages:           Number of write buffer pages ["
-              << mrg::journal2::JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
-    os << " -c --wcache_pgsize_sblks:        Size of each write buffer page in sblks (512 byte blocks) ["
-              << mrg::journal2::JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
-#else
-    os << " -d --jrnl_dir:                   Store directory [\""
-              << JournalParameters::_s_defaultJrnlDir << "\"]" << std::endl;
-    os << " -b --jrnl_base_filename:         Base name for journal files [\""
-              << JournalParameters::_s_defaultJrnlBaseFileName << "\"]" << std::endl;
-    os << " -f --num_jfiles:                 Number of journal files ["
-              << JournalParameters::_s_defaultNumJrnlFiles << "]" << std::endl;
-    os << " -s --jfsize_sblks:               Size of each journal file in sblks (512 byte blocks) ["
-              << JournalParameters::_s_defaultJrnlFileSize_sblks << "]" << std::endl;
-    os << " -a --auto_expand:                Auto-expand the journal ["
-              << (JournalParameters::_s_defaultAutoExpand?"T":"F") << "]" << std::endl;
-    os << " -e --ae_max_jfiles:              Upper limit on number of auto-expanded journal files ["
-              << JournalParameters::_s_defaultAutoExpandMaxJrnlFiles << "]" << std::endl;
-    os << " -p --wcache_num_pages:           Number of write buffer pages ["
-              << JournalParameters::_s_defaultWriteBuffNumPgs << "]" << std::endl;
-    os << " -c --wcache_pgsize_sblks:        Size of each write buffer page in sblks (512 byte blocks) ["
-              << JournalParameters::_s_defaultWriteBuffPgSize_sblks << "]" << std::endl;
-#endif
-}
-
-bool
-#ifdef JOURNAL2
-readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& sp)
-#else
-readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& sp)
-#endif
-{
-    static struct option long_options[] = {
-        {"help", no_argument, 0, 'h'},
-
-        // Test params
-        {"num_msgs", required_argument, 0, 'm'},
-        {"msg_size", required_argument, 0, 'S'},
-        {"num_queues", required_argument, 0, 'q'},
-        {"num_threads_per_queue", required_argument, 0, 't'},
-
-        // Journal params
-        {"jrnl_dir", required_argument, 0, 'd'},
-        {"jrnl_base_filename", required_argument, 0, 'b'},
-        {"num_jfiles", required_argument, 0, 'f'},
-        {"jfsize_sblks", required_argument, 0, 's'},
-        {"auto_expand", no_argument, 0, 'a'},
-        {"ae_max_jfiles", required_argument, 0, 'e'},
-        {"wcache_num_pages", required_argument, 0, 'p'},
-        {"wcache_pgsize_sblks", required_argument, 0, 'c'},
-
-        {0, 0, 0, 0}
-    };
-    bool err = false;
-    int c = 0;
-    while (true)
-    {
-        int option_index = 0;
-        c = getopt_long(argc, argv, "ab:c:d:e:f:hm:p:q:s:S:t:", long_options, &option_index);
-        if (c == -1) break;
-        switch (c)
-        {
-        // Test params
-        case 'm':
-            tp._numMsgs = uint32_t(std::atol(optarg));
-            break;
-        case 'S':
-            tp._msgSize = uint32_t(std::atol(optarg));
-            break;
-        case 'q':
-            tp._numQueues = uint16_t(std::atoi(optarg));
-            break;
-        case 't':
-            tp._numThreadPairsPerQueue = uint16_t(std::atoi(optarg));
-            break;
-
-        // Store params
-        case 'd':
-            sp._jrnlDir.assign(optarg);
-            break;
-        case 'b':
-            sp._jrnlBaseFileName.assign(optarg);
-            break;
-        case 'f':
-            sp._numJrnlFiles = uint16_t(std::atoi(optarg));
-            break;
-        case 's':
-            sp._jrnlFileSize_sblks = uint32_t(std::atol(optarg));
-            break;
-        case 'a':
-            sp._autoExpand = true;
-            break;
-        case 'e':
-            sp._autoExpandMaxJrnlFiles = uint16_t(std::atoi(optarg));
-            break;
-        case 'p':
-            sp._writeBuffNumPgs = uint16_t(std::atoi(optarg));
-            break;
-        case 'c':
-            sp._writeBuffPgSize_sblks = uint32_t(std::atol(optarg));
-            break;
-
-        // Other
-        case 'h':
-        default:
-            err = true;
-            printArgs();
-        }
-    }
-    return err;
-}
-
-} // namespace jtest
-} // namespace mrg
-
-// -----------------------------------------------------------------
-
-int
-main(int argc, char** argv)
-{
-    mrg::jtest::TestParameters tp;
-#ifdef JOURNAL2
-    mrg::journal2::JournalParameters jp;
-#else
-    mrg::jtest::JournalParameters jp;
-#endif
-    if (mrg::jtest::readArgs(argc, argv, tp, jp)) return 1;
-    std::cout << tp.toString() << std::endl;
-    std::cout << jp.toString() << std::endl;
-    mrg::jtest::StorePerformanceTest p(tp, jp);
-    p.run();
-
-    return 0;
-}

Deleted: store/trunk/cpp/perf/StorePerformanceTest.hpp
===================================================================
--- store/trunk/cpp/perf/StorePerformanceTest.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/StorePerformanceTest.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -1,140 +0,0 @@
-/**
- * \file StorePerformanceTest.hpp
- *
- * Qpid asynchronous store plugin library
- *
- * This file contains performance test code for the journal.
- *
- * \author Kim van der Riet
- *
- * Copyright (c) 2010 Red Hat, Inc.
- *
- * This file is part of the Qpid async store library msgstore.so.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- * USA
- *
- * The GNU Lesser General Public License is available in the file COPYING.
- */
-
-#ifndef mrg_jtest_StorePerformanceTest_hpp
-#define mrg_jtest_StorePerformanceTest_hpp
-
-#include <iostream>
-#include <vector>
-
-#include "JournalInstance.hpp"
-#include "TestParameters.hpp"
-
-#ifdef JOURNAL2
-#include "jrnl2/JournalParameters.hpp"
-#else
-#include "JournalParameters.hpp"
-#endif
-
-
-
-namespace mrg
-{
-namespace jtest
-{
-
-    /**
-     * \brief Main test class; Create an instance and execute run()
-     *
-     * Main test class which aggregates the components of a test.
-     */
-    class StorePerformanceTest
-    {
-        const TestParameters& _testParams;          ///< Ref to a struct containing test params
-#ifdef JOURNAL2
-        const mrg::journal2::JournalParameters& _jrnlParams; ///< Ref to a struct containing the journal parameters
-#else
-        const JournalParameters& _jrnlParams;       ///< Ref to a struct containing the journal parameters
-#endif
-        const char* msgData;                        ///< Pointer to msg data, which is the same for all messages
-        std::vector<JournalInstance*> _jrnlList;    ///< List of journals (JournalInstance instances) being tested
-
-        /**
-         * \brief Creates journals and JournalInstance classes for all journals (queues) to be tested
-         *
-         * Creates a new journal instance and JournalInstance instance for each queue. The journals are initialized
-         * which creates a new set of journal files on the local storage media (which is determined by path in
-         * JournalParameters._jrnlDir). This activity is not timed, and is not a part of the performance test per se.
-         */
-        void _prepareJournals();
-
-    public:
-        /**
-         * \brief Constructor
-         *
-         * Constructor.
-         *
-         * \param tp Test parameters for the test
-         * \param jp Journal parameters for all queues (journals) in the test
-         */
-#ifdef JOURNAL2
-        StorePerformanceTest(const TestParameters& tp, const mrg::journal2::JournalParameters& jp);
-#else
-        StorePerformanceTest(const TestParameters& tp, const JournalParameters& jp);
-#endif
-
-        /**
-         * \brief Destructor
-         *
-         * Destructor.
-         */
-        ~StorePerformanceTest();
-
-        /**
-         * \brief Runs the test and prints out the results.
-         *
-         * Runs the test  as set by the test parameters and journal parameters.
-         */
-        void run();
-    };
-
-    /**
-     * \brief Print out the program arguments
-     *
-     * Print out the arguments to the performance program if requested by help or a parameter error.
-     *
-     * \param os Stream to which the arguments should be streamed.
-     */
-    void printArgs(std::ostream& os = std::cout);
-
-    /**
-     * \brief Process the command-line arguments
-     *
-     * Process the command-line arguments and populate the TestParameters and JournalParameters structs. Only the
-     * arguments supplied are on the command-line are changed in these structs, the others remain unchanged. It is
-     * important therefore to make sure that defaults are pre-loaded (the default behavior of the default constructors
-     * for these structs).
-     *
-     * \param argc Number of command-line arguments.  Process directly from main().
-     * \param argv Pointer to array of command-line argument pointers. Process directly from main().
-     * \param tp Reference to test parameter object. Only params on the command-line are changed.
-     * \param jp Reference to journal parameter object. Only params on the command-line are changed.
-     */
-#ifdef JOURNAL2
-    bool readArgs(int argc, char** argv, TestParameters& tp, mrg::journal2::JournalParameters& jp);
-#else
-    bool readArgs(int argc, char** argv, TestParameters& tp, JournalParameters& jp);
-#endif
-
-} // namespace jtest
-} // namespace mrg
-
-#endif // mrg_jtest_StorePerformanceTest_hpp

Added: store/trunk/cpp/perf/Streamable.cpp
===================================================================
--- store/trunk/cpp/perf/Streamable.cpp	                        (rev 0)
+++ store/trunk/cpp/perf/Streamable.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,64 @@
+/**
+ * \file Streamable.cpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#include "Streamable.hpp"
+
+#include <sstream>
+
+namespace mrg
+{
+namespace jtest
+{
+
+    std::string
+    Streamable::toString() const
+    {
+        std::ostringstream oss;
+        toStream(oss);
+        return oss.str();
+    }
+
+    std::ostream&
+    operator<<(std::ostream& os, const Streamable& s)
+    {
+        s.toStream(os);
+        return os;
+    }
+
+    std::ostream&
+    operator<<(std::ostream& os, const Streamable* sPtr)
+    {
+        sPtr->toStream(os);
+        return os;
+    }
+
+} // namespace jtest
+} // namespace mrg

Added: store/trunk/cpp/perf/Streamable.hpp
===================================================================
--- store/trunk/cpp/perf/Streamable.hpp	                        (rev 0)
+++ store/trunk/cpp/perf/Streamable.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -0,0 +1,86 @@
+/**
+ * \file Streamable.hpp
+ *
+ * Qpid asynchronous store plugin library
+ *
+ * This file contains performance test code for the journal.
+ *
+ * \author Kim van der Riet
+ *
+ * Copyright (c) 2010 Red Hat, Inc.
+ *
+ * This file is part of the Qpid async store library msgstore.so.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ *
+ * The GNU Lesser General Public License is available in the file COPYING.
+ */
+
+#ifndef mrg_jtest_Streamable_hpp
+#define mrg_jtest_Streamable_hpp
+
+#include <iostream>
+#include <string>
+
+namespace mrg
+{
+namespace jtest
+{
+
+    /**
+     * \brief Abstract class which provides the mechanisms to stream
+     *
+     * An abstract class which provides stream functions. The toStream() function must be implemented by subclasses,
+     * and is used by the remaining functions. For convenience, toString() returns a std::string object.
+     */
+    struct Streamable
+    {
+        /**
+         * \brief Virtual destructor
+         */
+        virtual ~Streamable() {}
+
+        /***
+         * \brief Stream some representation of the object to an output stream
+         *
+         * \param os Output stream to which the class data is to be streamed
+         */
+        virtual void toStream(std::ostream& os = std::cout) const = 0;
+
+        /**
+         * \brief Creates a string representation of the test parameters
+         *
+         * Convenience feature which creates and returns a std::string object containing the content of toStream().
+         *
+         * \return Content of toStream()
+         */
+         std::string toString() const;
+
+        /**
+         * \brief Stream the object to an output stream
+         */
+        friend std::ostream& operator<<(std::ostream& os, const Streamable& s);
+
+        /**
+         * \brief Stream the object to an output stream through an object pointer
+         */
+        friend std::ostream& operator<<(std::ostream& os, const Streamable* sPtr);
+    };
+
+} // namespace jtest
+} // namespace mrg
+
+#endif // mrg_jtest_Streamable_hpp

Modified: store/trunk/cpp/perf/TestParameters.cpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.cpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/TestParameters.cpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -31,72 +31,65 @@
 
 #include "TestParameters.hpp"
 
-#include <sstream>
-
 namespace mrg
 {
 namespace jtest
 {
 
-// static declarations
-uint32_t TestParameters::_s_defaultNumMsgs = 100;
-uint32_t TestParameters::_s_defaultMsgSize = 10;
-uint16_t TestParameters::_s_defaultNumQueues = 1;
-uint16_t TestParameters::_s_defaultNumThreadPairsPerQueue = 1;
-uint16_t TestParameters::_s_defaultEnqTxnBlkSize = 0;
-uint16_t TestParameters::_s_defaultDeqTxnBlkSize = 0;
+    // static declarations
+    uint32_t TestParameters::_s_defaultNumMsgs = 100;
+    uint32_t TestParameters::_s_defaultMsgSize = 10;
+    uint16_t TestParameters::_s_defaultNumQueues = 1;
+    uint16_t TestParameters::_s_defaultNumThreadPairsPerQueue = 1;
+    uint16_t TestParameters::_s_defaultEnqTxnBlkSize = 0;
+    uint16_t TestParameters::_s_defaultDeqTxnBlkSize = 0;
 
-TestParameters::TestParameters():
-                               _numMsgs(_s_defaultNumMsgs),
-                               _msgSize(_s_defaultMsgSize),
-                               _numQueues(_s_defaultNumQueues),
-                               _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
-                               _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
-                               _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
-{}
+    TestParameters::TestParameters():
+                                   Streamable(),
+                                   _numMsgs(_s_defaultNumMsgs),
+                                   _msgSize(_s_defaultMsgSize),
+                                   _numQueues(_s_defaultNumQueues),
+                                   _numThreadPairsPerQueue(_s_defaultNumThreadPairsPerQueue),
+                                   _enqTxnBlockSize(_s_defaultEnqTxnBlkSize),
+                                   _deqTxnBlockSize(_s_defaultDeqTxnBlkSize)
+    {}
 
-TestParameters::TestParameters(const uint32_t numMsgs,
-                               const uint32_t msgSize,
-                               const uint16_t numQueues,
-                               const uint16_t numThreadPairsPerQueue,
-                               const uint16_t enqTxnBlockSize,
-                               const uint16_t deqTxnBlockSize) :
-                               _numMsgs(numMsgs),
-                               _msgSize(msgSize),
-                               _numQueues(numQueues),
-                               _numThreadPairsPerQueue(numThreadPairsPerQueue),
-                               _enqTxnBlockSize(enqTxnBlockSize),
-                               _deqTxnBlockSize(deqTxnBlockSize)
-{}
+    TestParameters::TestParameters(const uint32_t numMsgs,
+                                   const uint32_t msgSize,
+                                   const uint16_t numQueues,
+                                   const uint16_t numThreadPairsPerQueue,
+                                   const uint16_t enqTxnBlockSize,
+                                   const uint16_t deqTxnBlockSize) :
+                                   Streamable(),
+                                   _numMsgs(numMsgs),
+                                   _msgSize(msgSize),
+                                   _numQueues(numQueues),
+                                   _numThreadPairsPerQueue(numThreadPairsPerQueue),
+                                   _enqTxnBlockSize(enqTxnBlockSize),
+                                   _deqTxnBlockSize(deqTxnBlockSize)
+    {}
 
-TestParameters::TestParameters(const TestParameters& tp):
-                               _numMsgs(tp._numMsgs),
-                               _msgSize(tp._msgSize),
-                               _numQueues(tp._numQueues),
-                               _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
-                               _enqTxnBlockSize(tp._enqTxnBlockSize),
-                               _deqTxnBlockSize(tp._deqTxnBlockSize)
-{}
+    TestParameters::TestParameters(const TestParameters& tp):
+                                   Streamable(),
+                                   _numMsgs(tp._numMsgs),
+                                   _msgSize(tp._msgSize),
+                                   _numQueues(tp._numQueues),
+                                   _numThreadPairsPerQueue(tp._numThreadPairsPerQueue),
+                                   _enqTxnBlockSize(tp._enqTxnBlockSize),
+                                   _deqTxnBlockSize(tp._deqTxnBlockSize)
+    {}
 
-void
-TestParameters::toStream(std::ostream& os)
-{
-    os << "Test Parameters:" << std::endl;
-    os << "  num_msgs = " << _numMsgs << std::endl;
-    os << "  msg_size = " << _msgSize << std::endl;
-    os << "  num_queues = " << _numQueues << std::endl;
-    os << "  num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
-    os << "  enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
-    os << "  deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
-}
+    void
+    TestParameters::toStream(std::ostream& os) const
+    {
+        os << "Test Parameters:" << std::endl;
+        os << "  num_msgs = " << _numMsgs << std::endl;
+        os << "  msg_size = " << _msgSize << std::endl;
+        os << "  num_queues = " << _numQueues << std::endl;
+        os << "  num_thread_pairs_per_queue = " << _numThreadPairsPerQueue << std::endl;
+        os << "  enq_txn_blk_size = " << _enqTxnBlockSize << std::endl;
+        os << "  deq_txn_blk_size = " << _deqTxnBlockSize << std::endl;
+    }
 
-std::string
-TestParameters::toString()
-{
-    std::ostringstream oss;
-    toStream(oss);
-    return oss.str();
-}
-
 } // namespace jtest
 } // namespace mrg

Modified: store/trunk/cpp/perf/TestParameters.hpp
===================================================================
--- store/trunk/cpp/perf/TestParameters.hpp	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/TestParameters.hpp	2010-12-08 16:26:09 UTC (rev 4430)
@@ -32,9 +32,8 @@
 #ifndef mrg_jtest_TestParameters_hpp
 #define mrg_jtest_TestParameters_hpp
 
-#include <cstdint>
-#include <iostream>
-#include <string>
+#include <cstdint> // uint16_t, uint32_t
+#include "Streamable.hpp"
 
 namespace mrg
 {
@@ -47,7 +46,7 @@
      * This struct is used to aggregate and keep together all the test parameters. These affect the test itself, the
      * journal geometry is aggregated in class JournalParameters.
      */
-    struct TestParameters
+    struct TestParameters : public Streamable
     {
         static uint32_t _s_defaultNumMsgs;                  ///< Default number of messages to be sent
         static uint32_t _s_defaultMsgSize;                  ///< Default message size in bytes
@@ -92,12 +91,15 @@
         /**
          * \brief Copy constructor
          *
-         * Copy constructor.
-         *
          * \param tp Reference to TestParameters instance to be copied
          */
         TestParameters(const TestParameters& tp);
 
+        /**
+         * \brief Virtual destructor
+         */
+        virtual ~TestParameters() {}
+
         /***
          * \brief Stream the test parameters to an output stream
          *
@@ -106,17 +108,7 @@
          *
          * \param os Output stream to which the class data is to be streamed
          */
-        void toStream(std::ostream& os = std::cout);
-
-        /**
-         * \brief Creates a string representation of the test parameters
-         *
-         * Convenience feature which creates a multi-line string representation of all the test parameters, one
-         * per line.
-         *
-         * \return multi-line string representation of all the parameters, one parameter per line.
-         */
-        std::string toString();
+        void toStream(std::ostream& os = std::cout) const;
     };
 
 } // namespace jtest

Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m	2010-12-07 18:01:04 UTC (rev 4429)
+++ store/trunk/cpp/perf/m	2010-12-08 16:26:09 UTC (rev 4430)
@@ -5,7 +5,7 @@
 
 # The variable JOURNAL2, if defined, will link with the new journal2 namespace journal. Otherwise the old journal
 # namespace will be used.
-JOURNAL2=1
+#JOURNAL2=1
 
 # Optimization options
 #OPT="-O0 -ggdb"
@@ -16,26 +16,58 @@
             -Wmissing-field-initializers -Wpacked -Wredundant-decls -Wunreachable-code -Wno-invalid-offsetof \
             -Winvalid-pch -Wvolatile-register-var"
 
-PERF_FILES="StorePerformanceTest.cpp JournalInstance.cpp ScopedPerformanceTimer.cpp JournalParameters.cpp \
+PERF_FILES="JournalInstance.cpp \
+            JournalParameters.cpp \
+            JournalPerformanceTest.cpp \
+            PerformanceResult.cpp \
+            ScopedTimer.cpp \
+            Streamable.cpp \
             TestParameters.cpp"
 
 if [[ ${JOURNAL2}x == x ]] ; then
 
-JRNL_FILES="../lib/jrnl/aio.cpp ../lib/jrnl/enq_map.cpp ../lib/jrnl/jdir.cpp ../lib/jrnl/jrec.cpp ../lib/jrnl/rfc.cpp \
-  ../lib/jrnl/smutex.cpp ../lib/jrnl/wmgr.cpp ../lib/jrnl/cvar.cpp ../lib/jrnl/enq_rec.cpp ../lib/jrnl/jerrno.cpp \
-  ../lib/jrnl/lp_map.cpp ../lib/jrnl/rmgr.cpp ../lib/jrnl/time_ns.cpp ../lib/jrnl/wrfc.cpp ../lib/jrnl/data_tok.cpp \
-  ../lib/jrnl/fcntl.cpp ../lib/jrnl/jexception.cpp ../lib/jrnl/lpmgr.cpp ../lib/jrnl/rrfc.cpp ../lib/jrnl/txn_map.cpp \
-  ../lib/jrnl/deq_rec.cpp ../lib/jrnl/jcntl.cpp ../lib/jrnl/jinf.cpp ../lib/jrnl/pmgr.cpp ../lib/jrnl/slock.cpp \
-  ../lib/jrnl/txn_rec.cpp"
+JRNL_FILES="../lib/jrnl/aio.cpp \
+            ../lib/jrnl/enq_map.cpp \
+            ../lib/jrnl/jdir.cpp \
+            ../lib/jrnl/jrec.cpp \
+            ../lib/jrnl/rfc.cpp \
+            ../lib/jrnl/smutex.cpp \
+            ../lib/jrnl/wmgr.cpp \
+            ../lib/jrnl/cvar.cpp \
+            ../lib/jrnl/enq_rec.cpp \
+            ../lib/jrnl/jerrno.cpp \
+            ../lib/jrnl/lp_map.cpp \
+            ../lib/jrnl/rmgr.cpp \
+            ../lib/jrnl/time_ns.cpp \
+            ../lib/jrnl/wrfc.cpp \
+            ../lib/jrnl/data_tok.cpp \
+            ../lib/jrnl/fcntl.cpp \
+            ../lib/jrnl/jexception.cpp \
+            ../lib/jrnl/lpmgr.cpp \
+            ../lib/jrnl/rrfc.cpp \
+            ../lib/jrnl/txn_map.cpp \
+            ../lib/jrnl/deq_rec.cpp \
+            ../lib/jrnl/jcntl.cpp \
+            ../lib/jrnl/jinf.cpp \
+            ../lib/jrnl/pmgr.cpp \
+            ../lib/jrnl/slock.cpp \
+            ../lib/jrnl/txn_rec.cpp"
 WARN="${WARN_COMMON} ${WARN_OTHER}"
   
 else
 
 DEFINES=-DJOURNAL2
 
-JRNL_FILES="../lib/jrnl2/dtok.cpp ../lib/jrnl2/jdir.cpp ../lib/jrnl2/jexception.cpp ../lib/jrnl2/jrnl_state.cpp \
-  ../lib/jrnl2/smutex.cpp ../lib/jrnl2/dtok_state.cpp ../lib/jrnl2/jerrno.cpp ../lib/jrnl2/jrnl.cpp \
-  ../lib/jrnl2/slock.cpp ../lib/jrnl2/JournalParameters.cpp"
+JRNL_FILES="../lib/jrnl2/dtok.cpp \
+            ../lib/jrnl2/jdir.cpp \
+            ../lib/jrnl2/jexception.cpp \
+            ../lib/jrnl2/jrnl_state.cpp \
+            ../lib/jrnl2/smutex.cpp \
+            ../lib/jrnl2/dtok_state.cpp \
+            ../lib/jrnl2/jerrno.cpp \
+            ../lib/jrnl2/jrnl.cpp \
+            ../lib/jrnl2/slock.cpp \
+            ../lib/jrnl2/JournalParameters.cpp"
 WARN="${WARN_COMMON} ${WARN_OTHER} -Wshadow -Wunsafe-loop-optimizations"
 
 fi



More information about the rhmessaging-commits mailing list