From 6ba98a9f9f48e13738d9736cba9c45b5e94f42f2 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 14 Apr 2008 21:52:55 -0400 Subject: Initial import --- tests/stressnast.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/stressnast.c (limited to 'tests/stressnast.c') diff --git a/tests/stressnast.c b/tests/stressnast.c new file mode 100644 index 0000000..ad17a51 --- /dev/null +++ b/tests/stressnast.c @@ -0,0 +1,60 @@ +#include + +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + nasth *nasthole; + struct timeval before, after; + nast_options opts; + int i, rc; + + if (argc != 2) { + printf("Usage: %s query\n", argv[0]); + return 1; + } + + nasthole = nast_sphincter_new(NULL); + if (nasthole == NULL) { + fprintf(stderr, "ERROR: Couldn't connect to nasthole.\n"); + return 2; + } + + for (;;) { + /* Get the default options. */ + rc = nast_options_get(nasthole, &opts); + if (rc == -1) { + fprintf(stderr, "ERROR: Couldn't get options: %s.\n", + nast_errmsg(nasthole)); + nast_sphincter_close(nasthole); + return 2; + } + + for (i = 0; i < 10; i++) { + gettimeofday(&before, NULL); + rc = nast_get(nasthole, argv[1]); + gettimeofday(&after, NULL); + if (rc == -1) { + fprintf(stderr, + "ERROR: Couldn't perform query: %s.\n", + nast_errmsg(nasthole)); + nast_sphincter_close(nasthole); + return 2; + } + + after.tv_sec -= before.tv_sec; + after.tv_usec -= before.tv_usec; + if (after.tv_usec < 0) { + after.tv_sec--; + after.tv_usec += 1000000; + } + fprintf(stderr, "Request time: %2ld.%06ld seconds.\n", + after.tv_sec, after.tv_usec); + } + } + nast_sphincter_close(nasthole); + return 0; +} -- cgit v1.2.3