00001
00002 #include <SUM.h>
00003 #include <soi_key.h>
00004 #include <rpc/rpc.h>
00005 #include <sys/time.h>
00006 #include <sys/errno.h>
00007 #include <sum_rpc.h>
00008
00009 extern int errno;
00010 static struct timeval first[8], second[8];
00011 SUM_t *sum;
00012 float ftmp;
00013
00014
00015 void StartTimer(int n)
00016 {
00017 gettimeofday (&first[n], NULL);
00018 }
00019
00020 float StopTimer(int n)
00021 {
00022 gettimeofday (&second[n], NULL);
00023 if (first[n].tv_usec > second[n].tv_usec) {
00024 second[n].tv_usec += 1000000;
00025 second[n].tv_sec--;
00026 }
00027 return (float) (second[n].tv_sec-first[n].tv_sec) +
00028 (float) (second[n].tv_usec-first[n].tv_usec)/1000000.0;
00029 }
00030
00031 int main(int argc, char *argv[])
00032 {
00033 int bytes, msgtag, petid, req_num, status, cnt, i, j;
00034 uint64_t *dsixpt;
00035 char **cptr;
00036
00037 StartTimer(1);
00038 for(j =0; j< 10; j++) {
00039 StartTimer(2);
00040 if((sum = SUM_open(NULL, NULL, printf)) == 0) {
00041 printf("Failed on SUM_open()\n");
00042 exit(1);
00043 }
00044 ftmp = StopTimer(2);
00045 printf("Time SUM_Open = %fsec\n", ftmp);
00046 StartTimer(2);
00047 sum->mode = NORETRIEVE;
00048
00049 sum->tdays = 10;
00050 sum->reqcnt = 2;
00051 dsixpt = sum->dsix_ptr;
00052 *dsixpt++ = 131107;
00053 *dsixpt++ = 131103;
00054
00055 status = SUM_get(sum, printf);
00056 ftmp = StopTimer(2);
00057 printf("Time SUM_get = %fsec\n", ftmp);
00058 switch(status) {
00059 case 0:
00060 cnt = sum->reqcnt;
00061 cptr = sum->wd;
00062 printf("The wd's found from the SUM_get() call are:\n");
00063 for(i = 0; i < cnt; i++) {
00064 printf("wd = %s\n", *cptr++);
00065 }
00066 break;
00067 case 1:
00068 printf("Failed on SUM_get()\n");
00069 break;
00070 case RESULT_PEND:
00071 break;
00072 default:
00073 printf("Error: unknown status from SUM_get()\n");
00074 break;
00075 }
00076 StartTimer(2);
00077 SUM_close(sum, printf);
00078 ftmp = StopTimer(2);
00079 printf("Time SUM_Close = %fsec\n", ftmp);
00080 }
00081 ftmp = StopTimer(1);
00082 printf("Time Total = %fsec\n", ftmp);
00083
00084 }
00085