From: Mike Taylor Date: Wed, 24 Dec 2003 16:59:12 +0000 (+0000) Subject: Option parsing. Still no functionality. X-Git-Tag: YAZ.2.0.9~16 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=0d7bebc5bead24c1cdd6c3bfdc2a9bf2b3678c07 Option parsing. Still no functionality. Time to stop for Christmas. --- diff --git a/util/benchmark.c b/util/benchmark.c index 963e510..30405a9 100644 --- a/util/benchmark.c +++ b/util/benchmark.c @@ -1,18 +1,74 @@ -/* $Id: benchmark.c,v 1.1 2003-12-24 16:23:43 mike Exp $ - Copyright (C) 2003 - Index Data Aps +/* $Id: benchmark.c,v 1.2 2003-12-24 16:59:12 mike Exp $ + * Copyright (C) 2003 Index Data Aps + * + * This file is part of the YAZ toolkit. + * + * See the file LICENSE. + * + * This is an elementary benchmarker for server performance. It works + * by repeatedly connecting to, seaching in and retrieving from the + * specified server, and keeps statistics about the minimum, maximum + * and average times for each operation. + */ - This file is part of the YAZ toolkit. - - See the file LICENSE. -*/ - -#include #include +#include #include +struct options { + int nconnect; /* number of connections to make */ + int nsearch; /* number of searches on each connection */ + int npresent; /* number of presents for each search */ + int full; /* 1 = fetch full records, 0 = brief */ + int delay; /* number of ms to delay between ops */ + int random; /* if true, delay is random 0-specified */ +} options = { + 3, + 3, + 3, + 0, + 1000, + 1, +}; + + int main(int argc, char **argv) { + char *host; + int port; + int c; + + while ((c = getopt(argc, argv, "c:s:p:fbd:r")) != -1) { + switch (c) { + case 'c': options.nconnect = atoi(optarg); break; + case 's': options.nsearch = atoi(optarg); break; + case 'p': options.npresent = atoi(optarg); break; + case 'f': options.full = 1; break; + case 'b': options.full = 0; break; + case 'd': options.delay = atoi(optarg); break; + case 'r': options.random = 1; break; + default: goto USAGE; + } + } + + if (argc-optind != 2) { + USAGE: + fprintf(stderr, "Usage: %s [options] \n" +" -c Make connection to the server [default: 3]\n" +" -s Perform searches on each connection [3]\n" +" -p Make present requests after each search [3]\n" +" -f Fetch full records [default: brief]\n" +" -b Fetch brief records\n" +" -d Delay ms after each operation\n" +" -r Delays are random between 0 and the specified number of ms\n" +, argv[0]); + return 1; + } + + host = argv[optind]; + port = atoi(argv[optind+1]); + + return 0; }