[rhmessaging-commits] rhmessaging commits: r4431 - store/trunk/cpp/perf.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Dec 8 11:48:41 EST 2010


Author: kpvdr
Date: 2010-12-08 11:48:40 -0500 (Wed, 08 Dec 2010)
New Revision: 4431

Modified:
   store/trunk/cpp/perf/ScopedTimable.hpp
   store/trunk/cpp/perf/ScopedTimer.cpp
   store/trunk/cpp/perf/ScopedTimer.hpp
   store/trunk/cpp/perf/m
Log:
Perf code tidy-up: Replaced ugly access fn with friend class declaration

Modified: store/trunk/cpp/perf/ScopedTimable.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimable.hpp	2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimable.hpp	2010-12-08 16:48:40 UTC (rev 4431)
@@ -37,6 +37,18 @@
 namespace jtest
 {
 
+    class ScopedTimable;
+
+} // namespace jtest
+} // namespace mrg
+
+#include "ScopedTimer.hpp" // circular include
+
+namespace mrg
+{
+namespace jtest
+{
+
     /**
      * \brief Scoped timer class that starts timing on construction and finishes on destruction.
      *
@@ -64,15 +76,7 @@
          */
         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; }
+        friend class ScopedTimer;
     };
 
 } // namespace jtest

Modified: store/trunk/cpp/perf/ScopedTimer.cpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.cpp	2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimer.cpp	2010-12-08 16:48:40 UTC (rev 4431)
@@ -41,7 +41,7 @@
         ::clock_gettime(CLOCK_REALTIME, &_startTime);
     }
 
-    ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st.getElapsedRef())
+    ScopedTimer::ScopedTimer(ScopedTimable& st) : _elapsed(st._elapsed)
     {
         ::clock_gettime(CLOCK_REALTIME, &_startTime);
     }

Modified: store/trunk/cpp/perf/ScopedTimer.hpp
===================================================================
--- store/trunk/cpp/perf/ScopedTimer.hpp	2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/ScopedTimer.hpp	2010-12-08 16:48:40 UTC (rev 4431)
@@ -33,13 +33,25 @@
 #define mrg_jtest_ScopedTimer_hpp
 
 #include <ctime>
-#include "ScopedTimable.hpp"
 
+
 namespace mrg
 {
 namespace jtest
 {
 
+    class ScopedTimer;
+
+} // namespace jtest
+} // namespace mrg
+
+#include "ScopedTimable.hpp" // circular include
+
+namespace mrg
+{
+namespace jtest
+{
+
     /**
      * \brief Scoped timer class that starts timing on construction and finishes on destruction.
      *
@@ -82,7 +94,6 @@
          *
          * \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);
 
         /**

Modified: store/trunk/cpp/perf/m
===================================================================
--- store/trunk/cpp/perf/m	2010-12-08 16:26:09 UTC (rev 4430)
+++ store/trunk/cpp/perf/m	2010-12-08 16:48:40 UTC (rev 4431)
@@ -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"



More information about the rhmessaging-commits mailing list