X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fbenchmark.c;h=bf855f28c3ca0ae07853f9d666b99c1e467e103e;hp=95ca0535126ef60f45f11d93ae75ff7059f0ede8;hb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505;hpb=67002f49611adb64993391b0cbf6c235f18080a4 diff --git a/util/benchmark.c b/util/benchmark.c index 95ca053..bf855f2 100644 --- a/util/benchmark.c +++ b/util/benchmark.c @@ -1,4 +1,4 @@ -/* $Id: benchmark.c,v 1.7 2005-01-15 19:47:15 adam Exp $ +/* $Id: benchmark.c,v 1.8 2005-06-25 15:46:07 adam Exp $ * Copyright (C) 1995-2005, Index Data ApS * * This file is part of the YAZ toolkit. @@ -20,13 +20,13 @@ 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 */ - int verbosity; /* 0 = quiet, higher => more verbose */ + 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 */ + int verbosity; /* 0 = quiet, higher => more verbose */ } options = { 3, 3, @@ -51,47 +51,47 @@ int main(int argc, char **argv) int nok = 0; while ((c = getopt(argc, argv, "c:s:p:fbd:rv:")) != -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; - case 'v': options.verbosity = atoi(optarg); break; - default: goto USAGE; - } + 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; + case 'v': options.verbosity = atoi(optarg); 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" -" -v Set verbosity level to [0, silent on success]\n" + 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" +" -v Set verbosity level to [0, silent on success]\n" , argv[0]); - return 1; + return 1; } host = argv[optind]; port = atoi(argv[optind+1]); for (i = 0; i < options.nconnect; i++) { - db_printf(2, "iteration %d of %d", i+1, options.nconnect); - ok = test(host, port); - if (ok) nok++; + db_printf(2, "iteration %d of %d", i+1, options.nconnect); + ok = test(host, port); + if (ok) nok++; } db_printf(1, "passed %d of %d tests", nok, options.nconnect); if (nok < options.nconnect) - printf("Failed %d of %d tests\n", - options.nconnect-nok, options.nconnect); + printf("Failed %d of %d tests\n", + options.nconnect-nok, options.nconnect); return 0; @@ -106,8 +106,8 @@ static int test(char *host, int port) conn = ZOOM_connection_new(host, port); if ((error = ZOOM_connection_error(conn, &errmsg, &addinfo))) { - fprintf(stderr, "ZOOM error: %s (%d): %s\n", errmsg, error, addinfo); - return 0; + fprintf(stderr, "ZOOM error: %s (%d): %s\n", errmsg, error, addinfo); + return 0; } ZOOM_connection_destroy(conn); @@ -119,7 +119,7 @@ static void db_printf(int level, char *fmt, ...) va_list ap; if (level > options.verbosity) - return; + return; fprintf(stderr, "DEBUG(%d): ", level); va_start(ap, fmt); @@ -127,3 +127,11 @@ static void db_printf(int level, char *fmt, ...) fputc('\n', stderr); va_end(ap); } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +