diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-05 20:48:37 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-05 20:48:37 -0800 |
| commit | 621be916af307939f1bdcffe591bb139878bc48d (patch) | |
| tree | eee56ca86c21b6d85805eb41a7974c28683ac547 /perf | |
| parent | d28f9d935819a88fa799b99362b78a277b74fce8 (diff) | |
| download | nng-621be916af307939f1bdcffe591bb139878bc48d.tar.gz nng-621be916af307939f1bdcffe591bb139878bc48d.tar.bz2 nng-621be916af307939f1bdcffe591bb139878bc48d.zip | |
Add inproc performance tests.
Diffstat (limited to 'perf')
| -rw-r--r-- | perf/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | perf/perf.c | 90 |
2 files changed, 85 insertions, 7 deletions
diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt index 07c6480b..c5fc1c3a 100644 --- a/perf/CMakeLists.txt +++ b/perf/CMakeLists.txt @@ -43,3 +43,5 @@ add_nng_perf(remote_lat) add_nng_perf(local_lat) add_nng_perf(local_thr) add_nng_perf(remote_thr) +add_nng_perf(inproc_thr) +add_nng_perf(inproc_lat) diff --git a/perf/perf.c b/perf/perf.c index 5cd25545..36e563fc 100644 --- a/perf/perf.c +++ b/perf/perf.c @@ -29,6 +29,8 @@ static void do_remote_lat(int argc, char **argv); static void do_local_lat(int argc, char **argv); static void do_remote_thr(int argc, char **argv); static void do_local_thr(int argc, char **argv); +static void do_inproc_thr(int argc, char **argv); +static void do_inproc_lat(int argc, char **argv); static void die(const char *, ...); // perf implements the same performance tests found in the standard @@ -79,6 +81,10 @@ main(int argc, char **argv) } else if ((strcmp(prog, "remote_thr") == 0) || (strcmp(prog, "throughput_client") == 0)) { do_remote_thr(argc, argv); + } else if ((strcmp(prog, "inproc_thr") == 0)) { + do_inproc_thr(argc, argv); + } else if ((strcmp(prog, "inproc_lat") == 0)) { + do_inproc_lat(argc, argv); } else { die("Unknown program mode? Use -m <mode>."); } @@ -133,8 +139,8 @@ do_local_lat(int argc, char **argv) void do_remote_lat(int argc, char **argv) { - long int msgsize; - long int trips; + int msgsize; + int trips; if (argc != 3) { die("Usage: remote_lat <connect-to> <msg-size> <roundtrips>"); @@ -150,8 +156,8 @@ do_remote_lat(int argc, char **argv) void do_local_thr(int argc, char **argv) { - long int msgsize; - long int trips; + int msgsize; + int trips; if (argc != 3) { die("Usage: local_thr <listen-addr> <msg-size> <count>"); @@ -167,8 +173,8 @@ do_local_thr(int argc, char **argv) void do_remote_thr(int argc, char **argv) { - long int msgsize; - long int trips; + int msgsize; + int trips; if (argc != 3) { die("Usage: remote_thr <connect-to> <msg-size> <count>"); @@ -181,6 +187,76 @@ do_remote_thr(int argc, char **argv) } +struct inproc_args { + int count; + int msgsize; + const char * addr; + void (*func)(const char *, int, int); +}; + +static void +do_inproc(void *args) +{ + struct inproc_args *ia = args; + + ia->func(ia->addr, ia->msgsize, ia->count); +} + + +void +do_inproc_lat(int argc, char **argv) +{ + nni_thr thr; + struct inproc_args ia; + int rv; + + nni_init(); + if (argc != 2) { + die("Usage: inproc_lat <msg-size> <count>"); + } + + ia.addr = "inproc://latency_test"; + ia.msgsize = parse_int(argv[0], "message size"); + ia.count = parse_int(argv[1], "count"); + ia.func = latency_server; + + + if ((rv = nni_thr_init(&thr, do_inproc, &ia)) != 0) { + die("Cannot create thread: %s", nng_strerror(rv)); + } + nni_thr_run(&thr); + latency_client("inproc://latency_test", ia.msgsize, ia.count); + nni_thr_fini(&thr); +} + + +void +do_inproc_thr(int argc, char **argv) +{ + nni_thr thr; + struct inproc_args ia; + int rv; + + nni_init(); + if (argc != 2) { + die("Usage: inproc_thr <msg-size> <count>"); + } + + ia.addr = "inproc://tput_test"; + ia.msgsize = parse_int(argv[0], "message size"); + ia.count = parse_int(argv[1], "count"); + ia.func = throughput_client; + + + if ((rv = nni_thr_init(&thr, do_inproc, &ia)) != 0) { + die("Cannot create thread: %s", nng_strerror(rv)); + } + nni_thr_run(&thr); + throughput_server("inproc://tput_test", ia.msgsize, ia.count); + nni_thr_fini(&thr); +} + + void latency_client(const char *addr, int msgsize, int trips) { @@ -330,7 +406,7 @@ throughput_server(const char *addr, int msgsize, int count) printf("total time: %.3f [s]\n", total / 1000000.0); printf("message size: %d [B]\n", msgsize); printf("message count: %d\n", count); - printf("throughput: %.3f [msg/s]\n", msgpersec); + printf("throughput: %.f [msg/s]\n", msgpersec); printf("throughput: %.3f [Mb/s]\n", mbps); } |
