svn commit: samba r23533 - in branches/SAMBA_4_0/source/torture/nbench: .

tridge at samba.org tridge at samba.org
Sun Jun 17 20:03:32 GMT 2007


Author: tridge
Date: 2007-06-17 20:03:31 +0000 (Sun, 17 Jun 2007)
New Revision: 23533

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23533

Log:

added --option torture:targetrate=rate to target a particular
throughput in MBytes/sec

Modified:
   branches/SAMBA_4_0/source/torture/nbench/nbench.c
   branches/SAMBA_4_0/source/torture/nbench/nbio.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/nbench/nbench.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbench/nbench.c	2007-06-17 20:02:56 UTC (rev 23532)
+++ branches/SAMBA_4_0/source/torture/nbench/nbench.c	2007-06-17 20:03:31 UTC (rev 23533)
@@ -46,7 +46,12 @@
 	char *cname;
 	FILE *f;
 	BOOL correct = True;
+	double target_rate = lp_parm_double(-1, "torture", "targetrate", 0);	
 
+	if (target_rate != 0) {
+		printf("Targetting %.4f MByte/sec\n", target_rate);
+	}
+
 	if (torture_nprocs == 1) {
 		if (!read_only && !torture_setup_dir(cli, "\\clients")) {
 			return False;
@@ -86,6 +91,8 @@
 			nbio_time_delay(targett);
 			params++;
 			i--;
+		} else if (target_rate != 0) {
+			nbio_target_rate(target_rate);
 		}
 
 		if (i < 2 || params[0][0] == '#') continue;

Modified: branches/SAMBA_4_0/source/torture/nbench/nbio.c
===================================================================
--- branches/SAMBA_4_0/source/torture/nbench/nbio.c	2007-06-17 20:02:56 UTC (rev 23532)
+++ branches/SAMBA_4_0/source/torture/nbench/nbio.c	2007-06-17 20:03:31 UTC (rev 23533)
@@ -57,6 +57,29 @@
 	struct timeval starttime;
 } *children;
 
+void nbio_target_rate(double rate)
+{
+	static double last_bytes;
+	static struct timeval last_time;
+	double tdelay;
+
+	if (last_bytes == 0) {
+		last_bytes = children[nbio_id].bytes;
+		last_time = timeval_current();
+		return;
+	}
+
+	tdelay = (children[nbio_id].bytes - last_bytes)/(1.0e6*rate) - timeval_elapsed(&last_time);
+	if (tdelay > 0) {
+		msleep(tdelay*1000);
+	} else {
+		children[nbio_id].max_latency = MAX(children[nbio_id].max_latency, -tdelay);
+	}
+
+	last_time = timeval_current();
+	last_bytes = children[nbio_id].bytes;
+}
+
 void nbio_time_reset(void)
 {
 	children[nbio_id].starttime = timeval_current();	
@@ -68,7 +91,7 @@
 	if (targett > elapsed) {
 		msleep(1000*(targett - elapsed));
 	} else if (elapsed - targett > children[nbio_id].max_latency) {
-		children[nbio_id].max_latency = elapsed - targett;
+		children[nbio_id].max_latency = MAX(elapsed - targett, children[nbio_id].max_latency);
 	}
 }
 



More information about the samba-cvs mailing list