[Avida-SVN] r1652 - development/source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Jun 6 12:14:49 PDT 2007


Author: brysonda
Date: 2007-06-06 15:14:49 -0400 (Wed, 06 Jun 2007)
New Revision: 1652

Modified:
   development/source/tools/cRandom.cc
   development/source/tools/cRandom.h
Log:
Add basic debug support to cRandom.

Modified: development/source/tools/cRandom.cc
===================================================================
--- development/source/tools/cRandom.cc	2007-06-06 18:55:13 UTC (rev 1651)
+++ development/source/tools/cRandom.cc	2007-06-06 19:14:49 UTC (rev 1652)
@@ -40,6 +40,9 @@
 
 cRandom::cRandom(const int in_seed)
 : seed(0), original_seed(0), inext(0), inextp(0), expRV(0)
+#ifdef DEBUG_CRANDOM
+, m_call_count(0)
+#endif
 {
   for (int i = 0; i < 56; ++i) {
     ma[i] = 0;
@@ -118,6 +121,9 @@
 
 unsigned int cRandom::Get()
 {
+#ifdef DEBUG_CRANDOM
+  m_call_count++;
+#endif
   if (++inext == 56) inext = 0;
   if (++inextp == 56) inextp = 0;
   assert(inext < 56);

Modified: development/source/tools/cRandom.h
===================================================================
--- development/source/tools/cRandom.h	2007-06-06 18:55:13 UTC (rev 1651)
+++ development/source/tools/cRandom.h	2007-06-06 19:14:49 UTC (rev 1652)
@@ -43,6 +43,9 @@
   int inext;
   int inextp;
   int ma[56];
+#ifdef DEBUG_CRANDOM
+  long m_call_count;
+#endif
   
   // Constants ////////////////////////////////////////////////////////////////
   // Statistical Approximation
@@ -76,7 +79,12 @@
    **/
   cRandom(const int in_seed = -1);
   virtual ~cRandom() { ; }
+
   
+#ifdef DEBUG_CRANDOM
+  inline long GetCallCount() { return m_call_count; }
+#endif
+  
   /**
    * @return The seed that was actually used to start the random sequence.
    **/




More information about the Avida-cvs mailing list