From: Marc Cromme Date: Wed, 7 Sep 2005 13:45:15 +0000 (+0000) Subject: added simple benchmark client program written over zoom api X-Git-Tag: YAZ.2.1.10~84 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=d950c3e047f4ba482b7f36d7e81faae6d4b5dacb;p=yaz-moved-to-github.git added simple benchmark client program written over zoom api --- diff --git a/zoom/Makefile.am b/zoom/Makefile.am index 7aaeb2f..9212643 100644 --- a/zoom/Makefile.am +++ b/zoom/Makefile.am @@ -1,10 +1,10 @@ -## $Id: Makefile.am,v 1.14 2004-05-01 23:32:20 adam Exp $ +## $Id: Makefile.am,v 1.15 2005-09-07 13:45:15 marc Exp $ ## Copyright (C) 2001, Index Data AM_CPPFLAGS = -I$(top_srcdir)/include EXTRA_PROGRAMS = zoomtst1 zoomtst2 zoomtst3 zoomtst4 zoomtst5 zoomtst6 zoomtst7 zoomtst8 -bin_PROGRAMS = zoomsh +bin_PROGRAMS = zoomsh zoom-benchmark LDADD = ../src/libyaz.la $(READLINE_LIBS) @@ -17,3 +17,6 @@ zoomtst6_SOURCES = zoomtst6.c zoomtst7_SOURCES = zoomtst7.c zoomtst8_SOURCES = zoomtst8.c zoomsh_SOURCES = zoomsh.c +zoom_benchmark_SOURCES = zoom-benchmark.c + + diff --git a/zoom/zoom-benchmark.c b/zoom/zoom-benchmark.c new file mode 100644 index 0000000..19e83e8 --- /dev/null +++ b/zoom/zoom-benchmark.c @@ -0,0 +1,198 @@ +/* + * $Id: zoom-benchmark.c,v 1.1 2005-09-07 13:45:15 marc Exp $ + * + * Asynchronous multi-target client doing search and piggyback retrieval + */ + +#include +#include +#include +#include +#include + +#include +#include + + + + +int main(int argc, char **argv) +{ + + struct timeval now; + struct timeval then; + long sec=0, usec=0; + + int i; + int same_target = 0; + int no = argc-2; + ZOOM_connection z[1024]; /* allow at most 1024 connections */ + ZOOM_resultset r[1024]; /* and result sets .. */ + ZOOM_options o = ZOOM_options_create (); + + if (argc < 3) + { + fprintf (stderr, "usage:\n%s target1 target2 ... targetN query\n", + *argv); + exit (1); + } + if (argc == 4 && isdigit(argv[1][0]) && !strchr(argv[1],'.')) + { + no = atoi(argv[1]); + same_target = 1; + } + + if (no > 500) + no = 500; + + /* naming events */ + + //typedef enum { + // ZOOM_EVENT_NONE = 0, + // ZOOM_EVENT_CONNECT = 1, + // ZOOM_EVENT_SEND_DATA = 2, + // ZOOM_EVENT_RECV_DATA = 3, + // ZOOM_EVENT_TIMEOUT = 4, + // ZOOM_EVENT_UNKNOWN = 5, + // ZOOM_EVENT_SEND_APDU = 6, + // ZOOM_EVENT_RECV_APDU = 7, + // ZOOM_EVENT_RECV_RECORD = 8, + // ZOOM_EVENT_RECV_SEARCH = 9 + //} ZOOM_events; + + char* zoom_events[10]; + zoom_events[ZOOM_EVENT_NONE] = "ZOOM_EVENT_NONE"; + zoom_events[ZOOM_EVENT_CONNECT] = "ZOOM_EVENT_CONNECT"; + zoom_events[ZOOM_EVENT_SEND_DATA] = "ZOOM_EVENT_SEND_DATA"; + zoom_events[ZOOM_EVENT_RECV_DATA] = "ZOOM_EVENT_RECV_DATA"; + zoom_events[ZOOM_EVENT_TIMEOUT] = "ZOOM_EVENT_TIMEOUT"; + zoom_events[ZOOM_EVENT_UNKNOWN] = "ZOOM_EVENT_UNKNOWN"; + zoom_events[ZOOM_EVENT_SEND_APDU] = "ZOOM_EVENT_SEND_APDU"; + zoom_events[ZOOM_EVENT_RECV_APDU] = "ZOOM_EVENT_RECV_APDU"; + zoom_events[ZOOM_EVENT_RECV_RECORD] = "ZOOM_EVENT_RECV_RECORD"; + zoom_events[ZOOM_EVENT_RECV_SEARCH] = "ZOOM_EVENT_RECV_SEARCH"; + + int zoom_progress[10]; + zoom_progress[ZOOM_EVENT_NONE] = 0; + zoom_progress[ZOOM_EVENT_CONNECT] = 1; + zoom_progress[ZOOM_EVENT_SEND_DATA] = 3; + zoom_progress[ZOOM_EVENT_RECV_DATA] = 4; + zoom_progress[ZOOM_EVENT_TIMEOUT] = 8; + zoom_progress[ZOOM_EVENT_UNKNOWN] = 9; + zoom_progress[ZOOM_EVENT_SEND_APDU] = 2; + zoom_progress[ZOOM_EVENT_RECV_APDU] = 5; + zoom_progress[ZOOM_EVENT_RECV_RECORD] = 7; + zoom_progress[ZOOM_EVENT_RECV_SEARCH] = 6; + + + /* async mode */ + ZOOM_options_set (o, "async", "1"); + + /* get first 10 records of result set (using piggyback) */ + ZOOM_options_set (o, "count", "1"); + + /* preferred record syntax */ + //ZOOM_options_set (o, "preferredRecordSyntax", "usmarc"); + //ZOOM_options_set (o, "elementSetName", "F"); + + /* connect to all */ + for (i = 0; i