summaryrefslogtreecommitdiff
path: root/source4/torture/nbench/nbio.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-06-17 19:35:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:24 -0500
commit428373743a4c5fdde89daa6584dcfc67510319e5 (patch)
tree43ea50e9d3f5a627afe43bae1377ba0fc5916fc8 /source4/torture/nbench/nbio.c
parentde4f15a3ad0efaa02787839f29496abe9f5d5e80 (diff)
downloadsamba-428373743a4c5fdde89daa6584dcfc67510319e5.tar.gz
samba-428373743a4c5fdde89daa6584dcfc67510319e5.tar.bz2
samba-428373743a4c5fdde89daa6584dcfc67510319e5.zip
r23531: added optional latency reporting in BENCH-NBENCH. To use it, you need
to have a load file that puts a timestamp in the first column. That tells NBENCH to target the same throughput as the capture, and to report the maximum amount of latency miss in the test This allows you to quickly see how many clients you can run with while still meeting a given target (This used to be commit 7f045ca4f5e3e777978cad39ac22f0c611af6b10)
Diffstat (limited to 'source4/torture/nbench/nbio.c')
-rw-r--r--source4/torture/nbench/nbio.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c
index 26ea6520f6..a382c92ceb 100644
--- a/source4/torture/nbench/nbio.c
+++ b/source4/torture/nbench/nbio.c
@@ -53,8 +53,25 @@ static struct {
double bytes, warmup_bytes;
int line;
int done;
+ double max_latency;
+ struct timeval starttime;
} *children;
+void nbio_time_reset(void)
+{
+ children[nbio_id].starttime = timeval_current();
+}
+
+void nbio_time_delay(double targett)
+{
+ double elapsed = timeval_elapsed(&children[nbio_id].starttime);
+ if (targett > elapsed) {
+ msleep(1000*(targett - elapsed));
+ } else if (elapsed - targett > children[nbio_id].max_latency) {
+ children[nbio_id].max_latency = elapsed - targett;
+ }
+}
+
double nbio_result(void)
{
int i;
@@ -65,6 +82,19 @@ double nbio_result(void)
return 1.0e-6 * total / timeval_elapsed2(&tv_start, &tv_end);
}
+double nbio_latency(void)
+{
+ int i;
+ double max_latency = 0;
+ for (i=0;i<nprocs;i++) {
+ if (children[i].max_latency > max_latency) {
+ max_latency = children[i].max_latency;
+ children[i].max_latency = 0;
+ }
+ }
+ return max_latency;
+}
+
BOOL nb_tick(void)
{
return children[nbio_id].done;
@@ -122,9 +152,9 @@ void nb_alarm(int sig)
nprocs, lines/nprocs,
nbio_result(), t);
} else {
- printf("%4d %8d %.2f MB/sec execute %.0f sec \n",
+ printf("%4d %8d %.2f MB/sec execute %.0f sec latency %.2f msec \n",
nprocs, lines/nprocs,
- nbio_result(), t);
+ nbio_result(), t, nbio_latency() * 1.0e3);
}
fflush(stdout);
@@ -443,7 +473,7 @@ void nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status)
io.readx.in.remaining = 0;
io.readx.in.read_for_execute = False;
io.readx.out.data = buf;
-
+
ret = smb_raw_read(c->tree, &io);
free(buf);