summaryrefslogtreecommitdiff
path: root/perf
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-05 15:06:06 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-05 15:06:06 -0800
commitb17703d1e708a99e9a46ceb012676dc89df40df5 (patch)
treeb0626b66c0ada543ff6a4b46cb2e6751d789c132 /perf
parentad02a7fe3bf06a66f713ec68271d0962103f68c4 (diff)
downloadnng-b17703d1e708a99e9a46ceb012676dc89df40df5.tar.gz
nng-b17703d1e708a99e9a46ceb012676dc89df40df5.tar.bz2
nng-b17703d1e708a99e9a46ceb012676dc89df40df5.zip
Fix early termination, and buffer for throughput.
Diffstat (limited to 'perf')
-rw-r--r--perf/perf.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/perf/perf.c b/perf/perf.c
index d865db2b..5cd25545 100644
--- a/perf/perf.c
+++ b/perf/perf.c
@@ -284,11 +284,16 @@ throughput_server(const char *addr, int msgsize, int count)
int i;
size_t len;
uint64_t start, end;
- float msgpersec, mbps, total;
+ double msgpersec, mbps, total;
if ((rv = nng_open(&s, NNG_PROTO_PAIR)) != 0) {
die("nng_socket: %s", nng_strerror(rv));
}
+ len = 128;
+ rv = nng_setopt(s, NNG_OPT_RCVBUF, &len, sizeof (len));
+ if (rv != 0) {
+ die("nng_setopt(NNG_OPT_RCVBUF): %s", nng_strerror(rv));
+ }
// XXX: set no delay
// XXX: other options (TLS in the future?, Linger?)
@@ -319,7 +324,7 @@ throughput_server(const char *addr, int msgsize, int count)
end = nni_clock();
nng_close(s);
total = (end - start) / 1.0;
- msgpersec = count * 1000000 / total;
+ msgpersec = (count * 1000000.0) / total;
mbps = (count * 8.0 * msgsize);
mbps /= total;
printf("total time: %.3f [s]\n", total / 1000000.0);
@@ -337,6 +342,7 @@ throughput_client(const char *addr, int msgsize, int count)
nng_msg *msg;
int rv;
int i;
+ int len;
// We send one extra zero length message to start the timer.
count++;
@@ -348,6 +354,12 @@ throughput_client(const char *addr, int msgsize, int count)
// XXX: set no delay
// XXX: other options (TLS in the future?, Linger?)
+ len = 128;
+ rv = nng_setopt(s, NNG_OPT_SNDBUF, &len, sizeof (len));
+ if (rv != 0) {
+ die("nng_setopt(NNG_OPT_SNDBUF): %s", nng_strerror(rv));
+ }
+
if ((rv = nng_dial(s, addr, NULL, NNG_FLAG_SYNCH)) != 0) {
die("nng_dial: %s", nng_strerror(rv));
}
@@ -370,6 +382,6 @@ throughput_client(const char *addr, int msgsize, int count)
}
// Wait 100msec for pipes to drain.
- nng_close(s);
nni_usleep(100000);
+ nng_close(s);
}