diff options
Diffstat (limited to 'perf/perf.c')
| -rw-r--r-- | perf/perf.c | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/perf/perf.c b/perf/perf.c index 84a1c66f..593f635e 100644 --- a/perf/perf.c +++ b/perf/perf.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore <garrett@damore.org> -// Copyright 2017 Capitar IT Group BV <info@capitar.com> +// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -16,11 +16,7 @@ #include <stdlib.h> #include <string.h> -// We steal access to the clock and thread functions so that we can -// work on Windows too. These functions are *not* part of nng's public -// API, so don't be lazy like this! All nni_ symbols are subject to -// change without notice, and not part of the stable API or ABI. -#include "core/nng_impl.h" +#include "supplemental/util/platform.h" #if defined(NNG_ENABLE_PAIR1) #include "protocol/pair1/pair.h" @@ -224,11 +220,10 @@ do_inproc(void *args) void do_inproc_lat(int argc, char **argv) { - nni_thr thr; + nng_thread *thr; struct inproc_args ia; int rv; - nni_init(); if (argc != 2) { die("Usage: inproc_lat <msg-size> <count>"); } @@ -238,26 +233,24 @@ do_inproc_lat(int argc, char **argv) ia.count = parse_int(argv[1], "count"); ia.func = latency_server; - if ((rv = nni_thr_init(&thr, do_inproc, &ia)) != 0) { + if ((rv = nng_thread_create(&thr, do_inproc, &ia)) != 0) { die("Cannot create thread: %s", nng_strerror(rv)); } - nni_thr_run(&thr); // Sleep a bit. nng_msleep(100); latency_client("inproc://latency_test", ia.msgsize, ia.count); - nni_thr_fini(&thr); + nng_thread_destroy(thr); } void do_inproc_thr(int argc, char **argv) { - nni_thr thr; + nng_thread *thr; struct inproc_args ia; int rv; - nni_init(); if (argc != 2) { die("Usage: inproc_thr <msg-size> <count>"); } @@ -267,12 +260,11 @@ do_inproc_thr(int argc, char **argv) ia.count = parse_int(argv[1], "count"); ia.func = throughput_client; - if ((rv = nni_thr_init(&thr, do_inproc, &ia)) != 0) { + if ((rv = nng_thread_create(&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); + nng_thread_destroy(thr); } void @@ -280,7 +272,7 @@ latency_client(const char *addr, size_t msgsize, int trips) { nng_socket s; nng_msg * msg; - nni_time start, end; + nng_time start, end; int rv; int i; float total; @@ -301,7 +293,7 @@ latency_client(const char *addr, size_t msgsize, int trips) die("nng_msg_alloc: %s", nng_strerror(rv)); } - start = nni_clock(); + start = nng_clock(); for (i = 0; i < trips; i++) { if ((rv = nng_sendmsg(s, msg, 0)) != 0) { die("nng_sendmsg: %s", nng_strerror(rv)); @@ -311,9 +303,9 @@ latency_client(const char *addr, size_t msgsize, int trips) die("nng_recvmsg: %s", nng_strerror(rv)); } } - end = nni_clock(); + end = nng_clock(); - nni_msg_free(msg); + nng_msg_free(msg); nng_close(s); total = (float) ((end - start)) / 1000; @@ -395,8 +387,8 @@ throughput_server(const char *addr, size_t msgsize, int count) if ((rv = nng_recvmsg(s, &msg, 0)) != 0) { die("nng_recvmsg: %s", nng_strerror(rv)); } - nni_msg_free(msg); - start = nni_clock(); + nng_msg_free(msg); + start = nng_clock(); for (i = 0; i < count; i++) { if ((rv = nng_recvmsg(s, &msg, 0)) != 0) { @@ -406,9 +398,9 @@ throughput_server(const char *addr, size_t msgsize, int count) die("wrong message size: %d != %d", nng_msg_len(msg), msgsize); } - nni_msg_free(msg); + nng_msg_free(msg); } - end = nni_clock(); + end = nng_clock(); nng_close(s); total = (float) ((end - start)) / 1000; msgpersec = (float) (count) / total; |
