summaryrefslogtreecommitdiff
path: root/source4/torture/nbench
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-06-17 20:03:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:25 -0500
commit2a3282f872e4e415923626dbd86ce5b34b08be32 (patch)
treec8cf22b5b9150ac2de0a52ae0aecae1a56c0a6cc /source4/torture/nbench
parentfdbc8e29c7c87e415d7e43589234526722698bd6 (diff)
downloadsamba-2a3282f872e4e415923626dbd86ce5b34b08be32.tar.gz
r23533: added --option torture:targetrate=rate to target a particular
throughput in MBytes/sec (This used to be commit 35477e8e3d58acce467648f3bd83a43d135caefa)
Diffstat (limited to 'source4/torture/nbench')
-rw-r--r--source4/torture/nbench/nbench.c7
-rw-r--r--source4/torture/nbench/nbio.c25
2 files changed, 31 insertions, 1 deletions
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index eb67e15fbb3..f14da8cd15c 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -46,6 +46,11 @@ static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
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")) {
@@ -86,6 +91,8 @@ again:
nbio_time_delay(targett);
params++;
i--;
+ } else if (target_rate != 0) {
+ nbio_target_rate(target_rate);
}
if (i < 2 || params[0][0] == '#') continue;
diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c
index a382c92ceb9..f093ad82b04 100644
--- a/source4/torture/nbench/nbio.c
+++ b/source4/torture/nbench/nbio.c
@@ -57,6 +57,29 @@ static struct {
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 @@ void nbio_time_delay(double targett)
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);
}
}