[netperf-dev] netperf2 commit notice r521 - in trunk: doc src

raj at netperf.org raj at netperf.org
Tue Jan 31 11:36:28 PST 2012


Author: raj
Date: 2012-01-31 11:36:28 -0800 (Tue, 31 Jan 2012)
New Revision: 521

Modified:
   trunk/doc/netperf.html
   trunk/doc/netperf.texi
   trunk/src/netlib.c
   trunk/src/netlib.h
   trunk/src/netsh.c
   trunk/src/netsh.h
   trunk/src/nettest_bsd.c
   trunk/src/nettest_omni.c
Log:
make the demo mode code part of netlib.c and have nettest_omni.c and nettest_bsd.c use that to better centralize the code

Modified: trunk/doc/netperf.html
===================================================================
--- trunk/doc/netperf.html	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/doc/netperf.html	2012-01-31 19:36:28 UTC (rev 521)
@@ -2683,7 +2683,16 @@
       87380  16384  16384    10.03     233.96
 </pre>
    <p>We can take the sum of the results and be reasonably confident that
-the aggregate performance was 940 Mbits/s.
+the aggregate performance was 940 Mbits/s.  This method does not need
+to be limited to one system speaking to one other system.  It can be
+extended to one system talking to N other systems.  It could be as simple as:
+<pre class="example">     for host in 'foo bar baz bing'
+     do
+     netperf -t TCP_STREAM -H $hosts -i 10 -P 0 &amp;
+     done
+</pre>
+   <p>A more complicated/sophisticated example can be found in
+<samp><span class="file">doc/examples/runemomniagg2.sh</span></samp> where.
 
    <p>If you see warnings about netperf not achieving the confidence
 intervals, the best thing to do is to increase the number of
@@ -2741,9 +2750,9 @@
 </pre>
    <p>You will notice that the tests completed in an order other than they
 were started from the shell.  This underscores why there is a threat
-of skew error and why netperf4 is the preferred tool for aggregate
-tests.  Even if you see the Netperf Contributing Editor acting to the
-contrary!-)
+of skew error and why netperf4 will eventually be the preferred tool
+for aggregate tests.  Even if you see the Netperf Contributing Editor
+acting to the contrary!-)
 
 <ul class="menu">
 <li><a accesskey="1" href="#Issues-in-Running-Concurrent-Tests">Issues in Running Concurrent Tests</a>
@@ -3064,7 +3073,7 @@
 all the test systems.
 
    <p>While calls to get the current time can be inexpensive, that neither
-has nor is universally true.  For that reason netperf tries to
+has been nor is universally true.  For that reason netperf tries to
 minimize the number of such &ldquo;timestamping&rdquo; calls (eg
 <code>gettimeofday</code>) calls it makes when in demo mode.  Rather than
 take a timestamp after each <code>send</code> or <code>recv</code> call completes

Modified: trunk/doc/netperf.texi
===================================================================
(Binary files differ)

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/netlib.c	2012-01-31 19:36:28 UTC (rev 521)
@@ -247,6 +247,8 @@
 
 char *netperf_version;
 
+enum netperf_output_modes netperf_output_mode = HUMAN;
+
 /* in the past, I was overlaying a structure on an array of ints. now
    I am going to have a "real" structure, and point an array of ints
    at it. the real structure will be forced to the same alignment as
@@ -311,6 +313,7 @@
 }
 
 
+
 #ifdef WANT_INTERVALS
 static unsigned int usec_per_itvl;
 
@@ -3828,6 +3831,161 @@
 }
 #endif /* WIN32 */
 
+#if defined(WANT_INTERVALS) || defined(WANT_DEMO)
+
+int demo_mode;                    /* are we actually in demo mode? */
+double demo_interval = 1000000.0; /* what is the desired interval to
+				     display interval results. default
+				     is one second in units of
+				     microseconds */
+double demo_units = 0.0;          /* what is our current best guess as
+				     to how many work units must be
+				     done to be near the desired
+				     reporting interval? */ 
+
+double units_this_tick;
+#endif
+
+#ifdef WANT_DEMO
+#ifdef HAVE_GETHRTIME
+static hrtime_t demo_one;
+static hrtime_t demo_two;
+static hrtime_t *demo_one_ptr = &demo_one;
+static hrtime_t *demo_two_ptr = &demo_two;
+static hrtime_t *temp_demo_ptr = &demo_one;
+#elif defined(WIN32)
+static LARGE_INTEGER demo_one;
+static LARGE_INTEGER demo_two;
+static LARGE_INTEGER *demo_one_ptr = &demo_one;
+static LARGE_INTEGER *demo_two_ptr = &demo_two;
+static LARGE_INTEGER *temp_demo_ptr = &demo_one;
+#else
+static struct timeval demo_one;
+static struct timeval demo_two;
+static struct timeval *demo_one_ptr = &demo_one;
+static struct timeval *demo_two_ptr = &demo_two;
+static struct timeval *temp_demo_ptr = &demo_one;
+#endif 
+
+void demo_first_timestamp() {
+  HIST_timestamp(demo_one_ptr);
+}
+
+/* for a _STREAM test, "a" should be lss_size and "b" should be
+   rsr_size. for a _MAERTS test, "a" should be lsr_size and "b" should
+   be rss_size. raj 2005-04-06 */
+void demo_stream_setup(uint32_t a, uint32_t b) {
+  if ((demo_mode) && (demo_units == 0)) {
+    /* take our default value of demo_units to be the larger of
+       twice the remote's SO_RCVBUF or twice our SO_SNDBUF */
+    if (a > b) {
+      demo_units = 2*a;
+    }
+    else {
+      demo_units = 2*b;
+    }
+  }
+}
+
+/* this has gotten long enough to warrant being an inline function
+   rather than a macro, and it has been enough years since all the
+   important compilers have supported such a construct so it should
+   not be a big deal. raj 2012-01-23 */
+
+inline demo_interval_tick(uint32_t units) {
+  if (demo_mode) {
+    double actual_interval;
+    static int count = 0;
+    struct timeval now;
+    units_this_tick += units;
+    if (units_this_tick >= demo_units) {			
+      /* time to possibly update demo_units and maybe output an	
+	 interim result */					
+      HIST_timestamp(demo_two_ptr);				
+      actual_interval = delta_micro(demo_one_ptr,demo_two_ptr);	
+      /* we always want to fine-tune demo_units here whether we emit
+	 an interim result or not.  if we are short, this will
+	 lengthen demo_units.  if we are long, this will shorten it */
+      demo_units = demo_units * (demo_interval / actual_interval);
+      if (actual_interval >= demo_interval) {			
+        /* time to emit an interim result, giving the current time to
+	   the millisecond for compatability with RRD  */
+        gettimeofday(&now,NULL);
+	switch (netperf_output_mode) {
+	case HUMAN:
+	  fprintf(where,
+		  "Interim result: %7.2f %s/s over %.3f seconds ending at %ld.%.3ld\n",
+		  calc_thruput_interval(units_this_tick,
+					actual_interval/1000000.0),
+		  format_units(),
+		  actual_interval/1000000.0,
+		  now.tv_sec,
+		  (long) now.tv_usec/1000);
+	  break;
+	case CSV:
+	  fprintf(where,
+		  "%7.2f,%s/s,%.3f,%ld.%.3ld\n",
+		  calc_thruput_interval(units_this_tick,
+					actual_interval/1000000.0),
+		  format_units(),
+		  actual_interval/1000000.0,
+		  now.tv_sec,
+		  (long) now.tv_usec/1000);
+	  break;
+	case KEYVAL:
+	  fprintf(where,
+		  "NETPERF_INTERIM_RESULT[%d]=%.2f\n"
+		  "NETPERF_UNITS[%d]=%s/s\n"
+		  "NETPERF_INTERVAL[%d]=%.3f\n"
+		  "NETPERF_ENDING[%d]=%ld.%.3ld\n",
+		  count,
+		  calc_thruput_interval(units_this_tick,
+					actual_interval/1000000.0),
+		  count,
+		  format_units(),
+		  count,
+		  actual_interval/1000000.0,
+		  count,
+		  now.tv_sec,
+		  (long) now.tv_usec/1000);
+	  count += 1;
+	  break;
+	default:
+	  fprintf(where,
+		  "Hey Ricky you not fine, theres a bug at demo time. Hey Ricky!");
+	  fflush(where);
+	  exit(-1);
+	}
+	fflush(where);		
+	units_this_tick = 0.0;					
+	/* now get a new starting timestamp.  we could be clever
+	   and swap pointers - the math we do probably does not	
+	   take all that long, but for now this will suffice */	
+	temp_demo_ptr = demo_one_ptr;				
+	demo_one_ptr = demo_two_ptr;				
+	demo_two_ptr = temp_demo_ptr;				
+      }								
+    }								
+  }
+}
+
+void demo_stream_interval(uint32_t units) {
+  demo_interval_tick(units);
+}
+
+void demo_rr_setup(uint32_t a) {
+  if ((demo_mode) && (demo_units == 0)) {
+    /* take whatever we are given */
+    demo_units = a;
+  }
+}
+
+void demo_rr_interval(uint32_t units) {
+  demo_interval_tick(units);
+}
+
+#endif 
+
 /* hist.c
 
    Given a time difference in microseconds, increment one of 61

Modified: trunk/src/netlib.h
===================================================================
--- trunk/src/netlib.h	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/netlib.h	2012-01-31 19:36:28 UTC (rev 521)
@@ -242,6 +242,12 @@
   RECV_BUFFER
 };
 
+enum netperf_output_modes {
+  HUMAN = 0,
+  CSV,
+  KEYVAL,
+};
+
 /* some defines for security types, perhaps these would be better
    elsewhere but for now here they are */
 
@@ -480,6 +486,22 @@
 extern  FILE    *where;
 extern  int     loops_per_msec;
 extern  float   lib_local_per_cpu_util[];
+
+extern enum netperf_output_modes netperf_output_mode;
+
+#if defined(WANT_INTERVALS) || defined(WANT_DEMO)
+
+extern int    demo_mode;
+extern double demo_interval;
+extern double demo_units;
+extern double units_this_tick;
+#if defined(WANT_DEMO)
+extern void   demo_rr_interval(uint32_t units);
+extern void   demo_rr_setup(uint32_t units);
+extern void   demo_stream_interval(uint32_t units);
+extern void   demo_interval_tick(uint32_t units);
+#endif
+#endif 
   
 extern  void    netlib_init();
 extern  int     netlib_get_page_size();

Modified: trunk/src/netsh.c
===================================================================
--- trunk/src/netsh.c	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/netsh.c	2012-01-31 19:36:28 UTC (rev 521)
@@ -176,21 +176,7 @@
    of data traffic */
 int wait_time_secs = 0;
 
-#if defined(WANT_INTERVALS) || defined(WANT_DEMO)
 
-int demo_mode;                    /* are we actually in demo mode? */
-double demo_interval = 1000000.0; /* what is the desired interval to
-				     display interval results. default
-				     is one second in units of
-				     microseconds */
-double demo_units = 0.0;          /* what is our current best guess as
-				     to how many work units must be
-				     done to be near the desired
-				     reporting interval? */ 
-
-double units_this_tick;
-#endif
-
 #ifdef DIRTY
 int loc_dirty_count = 0,
     loc_clean_count = 0,

Modified: trunk/src/netsh.h
===================================================================
--- trunk/src/netsh.h	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/netsh.h	2012-01-31 19:36:28 UTC (rev 521)
@@ -140,14 +140,7 @@
 extern  int          remote_interval_usecs;
 extern  int          remote_interval_burst;
 
-#if defined(WANT_INTERVALS) || defined(WANT_DEMO)
 
-extern int    demo_mode;
-extern double demo_interval;
-extern double demo_units;
-extern double units_this_tick;
-#endif 
-
 #ifdef DIRTY
 extern int	rem_dirty_count;
 extern int	rem_clean_count;

Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/nettest_bsd.c	2012-01-31 19:36:28 UTC (rev 521)
@@ -334,91 +334,7 @@
 #endif
 #endif
 
-#ifdef WANT_DEMO
-#ifdef HAVE_GETHRTIME
-static hrtime_t demo_one;
-static hrtime_t demo_two;
-static hrtime_t *demo_one_ptr = &demo_one;
-static hrtime_t *demo_two_ptr = &demo_two;
-static hrtime_t *temp_demo_ptr = &demo_one;
-#elif defined(WIN32)
-static LARGE_INTEGER demo_one;
-static LARGE_INTEGER demo_two;
-static LARGE_INTEGER *demo_one_ptr = &demo_one;
-static LARGE_INTEGER *demo_two_ptr = &demo_two;
-static LARGE_INTEGER *temp_demo_ptr = &demo_one;
-#else
-static struct timeval demo_one;
-static struct timeval demo_two;
-static struct timeval *demo_one_ptr = &demo_one;
-static struct timeval *demo_two_ptr = &demo_two;
-static struct timeval *temp_demo_ptr = &demo_one;
-#endif 
 
-/* for a _STREAM test, "a" should be lss_size and "b" should be
-   rsr_size. for a _MAERTS test, "a" should be lsr_size and "b" should
-   be rss_size. raj 2005-04-06 */
-#define DEMO_STREAM_SETUP(a,b) \
-    if ((demo_mode) && (demo_units == 0)) { \
-      /* take our default value of demo_units to be the larger of \
-	 twice the remote's SO_RCVBUF or twice our SO_SNDBUF */ \
-      if (a > b) { \
-	demo_units = 2*a; \
-      } \
-      else { \
-	demo_units = 2*b; \
-      } \
-    }
-
-/* now that calc_thruput_interval knows about transactions as a format
-   we can merge DEMO_STREAM_INTERVAL and DEMO_RR_INTERVAL since the
-   are the same */
-
-#define DEMO_INTERVAL(units) \
-      if (demo_mode) { \
-	double actual_interval; \
-	units_this_tick += units; \
-	if (units_this_tick >= demo_units) { \
-	  /* time to possibly update demo_units and maybe output an \
-	     interim result */ \
-	  HIST_timestamp(demo_two_ptr); \
-	  actual_interval = delta_micro(demo_one_ptr,demo_two_ptr); \
-	  /* we always want to fine-tune demo_units here whether we \
-	     emit an interim result or not.  if we are short, this \
-	     will lengthen demo_units.  if we are long, this will \
-	     shorten it */ \
-	  demo_units = demo_units * (demo_interval / actual_interval); \
-	  if (actual_interval >= demo_interval) { \
-	    /* time to emit an interim result */ \
-	    fprintf(where, \
-		    "Interim result: %.2f %s/s over %.2f seconds\n", \
-		    calc_thruput_interval(units_this_tick, \
-					  actual_interval/1000000.0), \
-		    format_units(), \
-		    actual_interval/1000000.0); \
-	    units_this_tick = 0.0; \
-	    /* now get a new starting timestamp.  we could be clever \
-	       and swap pointers - the math we do probably does not \
-	       take all that long, but for now this will suffice */ \
-	    temp_demo_ptr = demo_one_ptr; \
-	    demo_one_ptr = demo_two_ptr; \
-	    demo_two_ptr = temp_demo_ptr; \
-	  } \
-	} \
-      }
-
-#define DEMO_STREAM_INTERVAL(units) DEMO_INTERVAL(units)
-
-#define DEMO_RR_SETUP(a) \
-    if ((demo_mode) && (demo_units == 0)) { \
-      /* take whatever we are given */ \
-	demo_units = a; \
-    }
-
-#define DEMO_RR_INTERVAL(units) DEMO_INTERVAL(units)
-
-#endif 
-
 char sockets_usage[] = "\n\
 Usage: netperf [global options] -- [test options] \n\
 \n\
@@ -2035,7 +1951,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_STREAM_SETUP(lss_size,rsr_size)
+    demo_stream_setup(lss_size,rsr_size);
 #endif
 
     /*Connect up to the remote port on the data socket  */
@@ -2101,7 +2017,7 @@
 
 #ifdef WANT_DEMO
       if (demo_mode) {
-	HIST_timestamp(demo_one_ptr);
+	demo_first_timestamp();
       }
 #endif
       
@@ -2155,7 +2071,7 @@
 #endif /* WANT_HISTOGRAM */      
 
 #ifdef WANT_DEMO
-      DEMO_STREAM_INTERVAL(send_size)
+      demo_stream_interval(send_size);
 #endif 
 
 #if defined(WANT_INTERVALS)
@@ -2748,7 +2664,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_STREAM_SETUP(lsr_size,rss_size)
+    demo_stream_setup(lsr_size,rss_size);
 #endif
 
     /*Connect up to the remote port on the data socket  */
@@ -2821,7 +2737,7 @@
 
 #ifdef WANT_DEMO
     if (demo_mode) {
-      HIST_timestamp(demo_one_ptr);
+      demo_first_timestamp();
     }
 #endif
 
@@ -2861,7 +2777,7 @@
 #endif /* DIRTY */
 
 #ifdef WANT_DEMO
-      DEMO_STREAM_INTERVAL(len);
+      demo_stream_interval(len);
 #endif
 
 #ifdef WANT_INTERVALS      
@@ -3677,7 +3593,7 @@
         }
 
 #if 0 /* def WANT_DEMO */
-        DEMO_STREAM_SETUP(lss_size,rsr_size)
+        demo_stream_setup(lss_size,rsr_size);
 #endif
 
             /*Connect up to the remote port on the data socket  */
@@ -3740,7 +3656,7 @@
 
 #if 0 /* def WANT_DEMO */
         if (demo_mode) {
-            HIST_timestamp(demo_one_ptr);
+	  demo_first_timestamp();
         }
 #endif
 
@@ -3836,7 +3752,7 @@
 #endif /* WANT_HISTOGRAM */
 
 #if 0 /* def WANT_DEMO */
-            DEMO_STREAM_INTERVAL(send_size);
+            demo_stream_interval(send_size);
 #endif
 
 #if 0 /* def WANT_INTERVALS */
@@ -4491,7 +4407,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_STREAM_SETUP(lss_size,rsr_size)
+    demo_stream_setup(lss_size,rsr_size);
 #endif
 
     /*Connect up to the remote port on the data socket  */
@@ -4558,7 +4474,7 @@
 
 #ifdef WANT_DEMO
     if (demo_mode) {
-      HIST_timestamp(demo_one_ptr);
+      demo_first_timestamp();
     }
 #endif
 
@@ -4662,7 +4578,7 @@
 #endif /* WANT_HISTOGRAM */      
     
 #ifdef WANT_DEMO
-      DEMO_STREAM_INTERVAL(send_size);
+      demo_stream_interval(send_size);
 #endif 
   
 #ifdef WANT_INTERVALS      
@@ -6002,7 +5918,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_RR_SETUP(1000)
+    demo_rr_setup(1000);
 #endif
 
     /*Connect up to the remote port on the data socket  */
@@ -6066,7 +5982,7 @@
 
 #ifdef WANT_DEMO
       if (demo_mode) {
-	HIST_timestamp(demo_one_ptr);
+	demo_first_timestamp();
       }
 #endif
 
@@ -6189,7 +6105,7 @@
 #endif /* WANT_HISTOGRAM */
 
 #ifdef WANT_DEMO
-      DEMO_RR_INTERVAL(1);
+      demo_rr_interval(1);
 #endif
 
 #ifdef WANT_INTERVALS      
@@ -6748,7 +6664,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_STREAM_SETUP(lss_size,rsr_size)
+    demo_stream_setup(lss_size,rsr_size);
 #endif
 
     /* We "connect" up to the remote post to allow is to use the send */
@@ -6808,7 +6724,7 @@
 
 #ifdef WANT_DEMO
     if (demo_mode) {
-      HIST_timestamp(demo_one_ptr);
+      demo_first_timetsamp();
     }
 #endif
 
@@ -6881,7 +6797,7 @@
 #endif /* WANT_HISTOGRAM */
 
 #ifdef WANT_DEMO
-      DEMO_STREAM_INTERVAL(send_size)
+      demo_stream_interval(send_size);
 #endif
 
 #ifdef WANT_INTERVALS      
@@ -7697,7 +7613,7 @@
     }
 
 #ifdef WANT_DEMO
-    DEMO_RR_SETUP(100)
+    demo_rr_setup(100);
 #endif
 
     /* Connect up to the remote port on the data socket. This will set */
@@ -7752,7 +7668,7 @@
 
 #ifdef WANT_DEMO
     if (demo_mode) {
-      HIST_timestamp(demo_one_ptr);
+      demo_first_timestamp();
     }
 #endif 
 
@@ -7838,7 +7754,7 @@
       /* millisecond.  */
 
 #ifdef WANT_DEMO
-      DEMO_RR_INTERVAL(1);
+      demo_rr_interval(1);
 #endif
 
 #ifdef WANT_INTERVALS      
@@ -9095,7 +9011,7 @@
     }
   }
 #ifdef WANT_DEMO
-  DEMO_RR_SETUP(100)
+  demo_rr_setup(100);
 #endif
 
   /* pick a nice random spot between client_port_min and */
@@ -9134,7 +9050,7 @@
 
 #ifdef WANT_DEMO
       if (demo_mode) {
-	HIST_timestamp(demo_one_ptr);
+	demo_first_timestamp();
       }
 #endif
   
@@ -9318,7 +9234,7 @@
 #endif /* WANT_HISTOGRAM */
 
 #ifdef WANT_DEMO
-      DEMO_RR_INTERVAL(1)
+      demo_rr_interval(1);
 #endif
 
       nummessages++;          
@@ -12286,7 +12202,7 @@
   }
 
 #ifdef WANT_DEMO
-  DEMO_RR_SETUP(100)
+  demo_rr_setup(100);
 #endif
   
   /* pick a nice random spot between client_port_min and */
@@ -12325,7 +12241,7 @@
 
 #ifdef WANT_DEMO
   if (demo_mode) {
-    HIST_timestamp(demo_one_ptr);
+    demo_first_timestamp();
   }
 #endif
 
@@ -12436,7 +12352,7 @@
 #endif /* WANT_HISTOGRAM */
 
 #ifdef WANT_DEMO
-      DEMO_RR_INTERVAL(1)
+      demo_rr_interval(1);
 #endif
 
       nummessages++;          

Modified: trunk/src/nettest_omni.c
===================================================================
--- trunk/src/nettest_omni.c	2012-01-30 23:04:00 UTC (rev 520)
+++ trunk/src/nettest_omni.c	2012-01-31 19:36:28 UTC (rev 521)
@@ -135,140 +135,8 @@
 
 static HIST time_hist;
 
-enum netperf_output_modes {
-  HUMAN = 0,
-  CSV,
-  KEYVAL,
-};
-enum netperf_output_modes netperf_output_mode = HUMAN;
 
-#ifdef WANT_DEMO
-#ifdef HAVE_GETHRTIME
-static hrtime_t demo_one;
-static hrtime_t demo_two;
-static hrtime_t *demo_one_ptr = &demo_one;
-static hrtime_t *demo_two_ptr = &demo_two;
-static hrtime_t *temp_demo_ptr = &demo_one;
-#elif defined(WIN32)
-static LARGE_INTEGER demo_one;
-static LARGE_INTEGER demo_two;
-static LARGE_INTEGER *demo_one_ptr = &demo_one;
-static LARGE_INTEGER *demo_two_ptr = &demo_two;
-static LARGE_INTEGER *temp_demo_ptr = &demo_one;
-#else
-static struct timeval demo_one;
-static struct timeval demo_two;
-static struct timeval *demo_one_ptr = &demo_one;
-static struct timeval *demo_two_ptr = &demo_two;
-static struct timeval *temp_demo_ptr = &demo_one;
-#endif 
 
-/* for a _STREAM test, "a" should be lss_size and "b" should be
-   rsr_size. for a _MAERTS test, "a" should be lsr_size and "b" should
-   be rss_size. raj 2005-04-06 */
-#define DEMO_STREAM_SETUP(a,b) \
-    if ((demo_mode) && (demo_units == 0)) { \
-      /* take our default value of demo_units to be the larger of \
-	 twice the remote's SO_RCVBUF or twice our SO_SNDBUF */ \
-      if (a > b) { \
-	demo_units = 2*a; \
-      } \
-      else { \
-	demo_units = 2*b; \
-      } \
-    }
-
-/* this has gotten long enough to make a static inline, and it has been enough years since all the important compilers have supported such a construct so it shold not be a big deal. raj 2012-01-23 */
-
-static inline DEMO_INTERVAL(uint32_t units) {
-  if (demo_mode) {
-    double actual_interval;
-    static int count = 0;
-    struct timeval now;
-    units_this_tick += units;		
-    if (units_this_tick >= demo_units) {			
-      /* time to possibly update demo_units and maybe output an	
-	 interim result */					
-      HIST_timestamp(demo_two_ptr);				
-      actual_interval = delta_micro(demo_one_ptr,demo_two_ptr);	
-      /* we always want to fine-tune demo_units here whether we emit
-	 an interim result or not.  if we are short, this will
-	 lengthen demo_units.  if we are long, this will shorten it */
-      demo_units = demo_units * (demo_interval / actual_interval);
-      if (actual_interval >= demo_interval) {			
-        /* time to emit an interim result, giving the current time to
-	   the millisecond for compatability with RRD  */
-        gettimeofday(&now,NULL);
-	switch (netperf_output_mode) {
-	case HUMAN:
-	  fprintf(where,
-		  "Interim result: %7.2f %s/s over %.3f seconds ending at %ld.%.3ld\n",
-		  calc_thruput_interval(units_this_tick,
-					actual_interval/1000000.0),
-		  format_units(),
-		  actual_interval/1000000.0,
-		  now.tv_sec,
-		  (long) now.tv_usec/1000);
-	  break;
-	case CSV:
-	  fprintf(where,
-		  "%7.2f,%s/s,%.3f,%ld.%.3ld\n",
-		  calc_thruput_interval(units_this_tick,
-					actual_interval/1000000.0),
-		  format_units(),
-		  actual_interval/1000000.0,
-		  now.tv_sec,
-		  (long) now.tv_usec/1000);
-	  break;
-	case KEYVAL:
-	  fprintf(where,
-		  "NETPERF_INTERIM_RESULT[%d]=%.2f\n"
-		  "NETPERF_UNITS[%d]=%s/s\n"
-		  "NETPERF_INTERVAL[%d]=%.3f\n"
-		  "NETPERF_ENDING[%d]=%ld.%.3ld\n",
-		  count,
-		  calc_thruput_interval(units_this_tick,
-					actual_interval/1000000.0),
-		  count,
-		  format_units(),
-		  count,
-		  actual_interval/1000000.0,
-		  count,
-		  now.tv_sec,
-		  (long) now.tv_usec/1000);
-	  count += 1;
-	  break;
-	default:
-	  fprintf(where,
-		  "Hey Ricky you not fine, theres a bug at demo time. Hey Ricky!");
-	  fflush(where);
-	  exit(-1);
-	}
-	fflush(where);		
-	units_this_tick = 0.0;					
-	/* now get a new starting timestamp.  we could be clever
-	   and swap pointers - the math we do probably does not	
-	   take all that long, but for now this will suffice */	
-	temp_demo_ptr = demo_one_ptr;				
-	demo_one_ptr = demo_two_ptr;				
-	demo_two_ptr = temp_demo_ptr;				
-      }								
-    }								
-  }
-}
-
-#define DEMO_STREAM_INTERVAL(units) DEMO_INTERVAL(units)
-
-#define DEMO_RR_SETUP(a) \
-    if ((demo_mode) && (demo_units == 0)) { \
-      /* take whatever we are given */ \
-	demo_units = a; \
-    }
-
-#define DEMO_RR_INTERVAL(units) DEMO_INTERVAL(units)
-
-#endif 
-
 #ifdef WANT_INTERVALS
 int interval_count;
 unsigned int interval_wait_microseconds;
@@ -3795,7 +3663,7 @@
     /* at some point we will have to be more clever about this, but
        for now we won't */
 
-    DEMO_RR_SETUP(100);
+    demo_rr_setup(100);
 #endif
 
     /* if we are not a connectionless protocol, we need to connect. at
@@ -3848,7 +3716,7 @@
 
 #ifdef WANT_DEMO
     if (demo_mode) {
-      HIST_timestamp(demo_one_ptr);
+      demo_first_timestamp();
     }
 #endif
     
@@ -4184,13 +4052,13 @@
     
 #ifdef WANT_DEMO
       if (NETPERF_IS_RR(direction)) {
-	DEMO_INTERVAL(1);
+	demo_interval_tick(1);
       }
       else if (NETPERF_XMIT_ONLY(direction)) {
-	DEMO_INTERVAL(bytes_to_send);
+	demo_interval_tick(bytes_to_send);
       }
       else {
-	DEMO_INTERVAL(rret);
+	demo_interval_tick(rret);
       }
 #endif
 



More information about the netperf-dev mailing list