[BACK]Return to patch-ab CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / benchmarks / nttcp / patches

File: [cvs.NetBSD.org] / pkgsrc / benchmarks / nttcp / patches / patch-ab (download)

Revision 1.3, Fri May 12 03:07:14 2006 UTC (15 years, 6 months ago) by simonb
Branch: MAIN
CVS Tags: pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, pkgsrc-2014Q2-base, pkgsrc-2014Q2, pkgsrc-2014Q1-base, pkgsrc-2014Q1, pkgsrc-2013Q4-base, pkgsrc-2013Q4, pkgsrc-2013Q3-base, pkgsrc-2013Q3, pkgsrc-2013Q2-base, pkgsrc-2013Q2, pkgsrc-2013Q1-base, pkgsrc-2013Q1, pkgsrc-2012Q4-base, pkgsrc-2012Q4, pkgsrc-2012Q3-base, pkgsrc-2012Q3, pkgsrc-2012Q2-base, pkgsrc-2012Q2, pkgsrc-2012Q1-base, pkgsrc-2012Q1, pkgsrc-2011Q4-base, pkgsrc-2011Q4, pkgsrc-2011Q3-base, pkgsrc-2011Q3, pkgsrc-2011Q2-base, pkgsrc-2011Q2, pkgsrc-2011Q1-base, pkgsrc-2011Q1, pkgsrc-2010Q4-base, pkgsrc-2010Q4, pkgsrc-2010Q3-base, pkgsrc-2010Q3, pkgsrc-2010Q2-base, pkgsrc-2010Q2, pkgsrc-2010Q1-base, pkgsrc-2010Q1, pkgsrc-2009Q4-base, pkgsrc-2009Q4, pkgsrc-2009Q3-base, pkgsrc-2009Q3, pkgsrc-2009Q2-base, pkgsrc-2009Q2, pkgsrc-2009Q1-base, pkgsrc-2009Q1, pkgsrc-2008Q4-base, pkgsrc-2008Q4, pkgsrc-2008Q3-base, pkgsrc-2008Q3, pkgsrc-2008Q2-base, pkgsrc-2008Q2, pkgsrc-2008Q1-base, pkgsrc-2008Q1, pkgsrc-2007Q4-base, pkgsrc-2007Q4, pkgsrc-2007Q3-base, pkgsrc-2007Q3, pkgsrc-2007Q2-base, pkgsrc-2007Q2, pkgsrc-2007Q1-base, pkgsrc-2007Q1, pkgsrc-2006Q4-base, pkgsrc-2006Q4, pkgsrc-2006Q3-base, pkgsrc-2006Q3, pkgsrc-2006Q2-base, pkgsrc-2006Q2, cwrapper, cube-native-xorg-base, cube-native-xorg
Changes since 1.2: +105 -4 lines

Add a new -U option, to run for a given time instead of for a given
number of buffers.
Bump PKGREVISION.

Not feed upsteam as author seems to have disappeared :(

$NetBSD: patch-ab,v 1.3 2006/05/12 03:07:14 simonb Exp $

--- nttcp.c.orig	2000-12-18 21:16:54.000000000 +1100
+++ nttcp.c
@@ -136,9 +136,9 @@ void syslog(int priority, const char *me
 #endif /* aix */ 
 
 /*====================================================================*/
-#if defined(FreeBSD)
+#ifndef SIGCLD
 #define	SIGCLD	SIGCHLD
-#endif /*FreeBSD*/
+#endif /*SIGCLD*/
 
 /*====================================================================*/
 #if defined(BSD42)
@@ -268,6 +268,7 @@ Usage: nttcp [local options] host [remot
 \t-n#	number of source bufs written to network (default 2048)\n\
 \t-u	use UDP instead of TCP\n\
 \t-g#us	gap in micro seconds between UDP packets (default 0s)\n\
+\t-U#	run until a number of seconds have elapsed\n\
 \t-d	set SO_DEBUG in sockopt\n\
 \t-D	don't buffer TCP writes (sets TCP_NODELAY socket option)\n\
 \t-w#	set the send buffer space to #kilobytes, which is\n\
@@ -346,6 +347,7 @@ typedef struct {
     int FixedDataSize;		/* if>0: calc BufCnt/BufLen from this */
     int Window,	SndWin, RcvWin; /* TCP window sizes */
     int	Verbose;		/* ==1: more diagnostics */
+    int RunTime;		/* approximate runtime in seconds */
     char *MulticastChannel;	/* we send multicast traffic */
     short MulticastPort;	
     int GapLength;		/* Gap length between packets */
@@ -496,6 +498,13 @@ void StartTimer() {
     SysCalls=0;
 }
 
+int CheckTimer() {
+    TimeVal now;
+
+    gettimeofday(&now, (struct timezone *)0);
+    return opt.RunTime < (now.tv_sec - time0.tv_sec);
+}
+
 void StopTimer(double *cput, double *realt) {
     /* delivers in cput:  the amount of cpu time in seconds
      *          in realt: the real time in seconds
@@ -878,6 +887,7 @@ void InitOptions(Options *opt) {
     opt->Verbose=0;		/* ==1: more diagnostics */
     opt->GapLength=0;		/* no delay, send as fast as possible */
     opt->inetd= 0;		/* ==1: run in inetd mode */
+    opt->RunTime = 0;		/* run effectively forever (ie BufCnt is limiting factor) */
     opt->Service= GetService();	/* the service-port to listen to */
     opt->MulticastChannel= NULL;
     opt->MulticastPort= 0;
@@ -1013,6 +1023,10 @@ void ParseOptions(int *ac, char **av[], 
 #endif /*MULTICAST*/
 	    break;
 	  }
+	  case 'U':
+	    GetSizeValue(&argc, &argv, &opt->RunTime, 1000000000,
+	      "runtime");
+	    break;
 	  default: {
 	    strcpy(MsgBuf, "unknown option: ");
 	    strncat(MsgBuf, argv[0], sizeof(MsgBuf)-strlen(MsgBuf)-1);
@@ -1427,6 +1441,10 @@ int main(int argc, char *argv[]) {
 	    sprintf(OptBuf, "-g%d", opt.GapLength);
 	    StrVecAppend(RemOpt, OptBuf);
 	}
+	if (opt.RunTime > 0) {
+	    sprintf(OptBuf, "-U%d", opt.RunTime);
+	    StrVecAppend(RemOpt, OptBuf);
+	}
 	if (opt.MulticastChannel) {
 	    sprintf(OptBuf, "-m%s:%d",
 	      opt.MulticastChannel, opt.MulticastPort);
@@ -1781,9 +1799,17 @@ int main(int argc, char *argv[]) {
 	    else
 		Pattern(buf, opt.BufLen);
 	    StartTimer();
-	    while (n-- && Nwrite(fd, buf, opt.BufLen) == opt.BufLen) {
+	    while (Nwrite(fd, buf, opt.BufLen) == opt.BufLen) {
 		nBytes+= opt.BufLen;
 		nBuffer++;
+		if (opt.RunTime == 0) {
+		    if (--n == 0)
+			break;
+		} else {
+		    /* XXX: tune how often to check if timer has expired? */
+		    if ((nBuffer % 100 == 0) && CheckTimer())
+			break;
+		}
 	    }
 	    StopTimer(&cput, &realt);
 	    opt.GapLength= 0;
@@ -1797,9 +1823,17 @@ int main(int argc, char *argv[]) {
 	    nBytes= 0;
 	    nBuffer= 0;
 	    StartTimer();
-	    while (n-- && Nwrite(fd, buf, opt.BufLen) == opt.BufLen) {
+	    while (Nwrite(fd, buf, opt.BufLen) == opt.BufLen) {
 		nBytes+= opt.BufLen;
 		nBuffer++;
+		if (opt.RunTime == 0) {
+		    if (--n == 0)
+			break;
+		} else {
+		    /* XXX: tune how often to check if timer has expired? */
+		    if ((nBuffer % 100 == 0) && CheckTimer())
+			break;
+		}
 	    }
 	    StopTimer(&cput, &realt);
 	}