Converted buckTest.c to use epicsTime.h instead of time.h

This should finally resolve the build conflict between RTEMS-uc5282
and Windows, and remove the build warning on vxWorks.
This commit is contained in:
Andrew Johnson
2010-08-17 17:53:43 -05:00
parent 7af0397d58
commit a6a01e6822
+61 -65
View File
@@ -7,9 +7,9 @@
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#include <time.h>
#include <stdio.h>
#include "epicsTime.h"
#include "epicsAssert.h"
#include "bucketLib.h"
#include "testMain.h"
@@ -19,68 +19,64 @@
MAIN(buckTest)
{
unsigned id1;
unsigned id2;
char *pValSave1;
char *pValSave2;
int s;
BUCKET *pb;
char *pVal;
unsigned i;
clock_t start, finish;
double duration;
const int LOOPS = 500000;
pb = bucketCreate(8);
if(!pb){
return -1;
}
id1 = 0x1000a432;
pValSave1 = "fred";
s = bucketAddItemUnsignedId(pb, &id1, pValSave1);
verify (s == S_bucket_success);
pValSave2 = "jane";
id2 = 0x0000a432;
s = bucketAddItemUnsignedId(pb, &id2, pValSave2);
verify (s == S_bucket_success);
start = clock();
for(i=0; i<LOOPS; i++){
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id2);
verify (pVal == pValSave2);
}
finish = clock();
duration = finish-start;
duration = duration/CLOCKS_PER_SEC;
printf("It took %15.10f total sec\n", duration);
duration = duration/LOOPS;
duration = duration/10;
duration = duration * 1e6;
printf("It took %15.10f u sec per hash lookup\n", duration);
bucketShow(pb);
return S_bucket_success;
}
unsigned id1;
unsigned id2;
char * pValSave1;
char * pValSave2;
int s;
BUCKET * pb;
char * pVal;
unsigned i;
epicsTimeStamp start, finish;
double duration;
const int LOOPS = 500000;
pb = bucketCreate(8);
if (!pb) {
return -1;
}
id1 = 0x1000a432;
pValSave1 = "fred";
s = bucketAddItemUnsignedId(pb, &id1, pValSave1);
verify (s == S_bucket_success);
pValSave2 = "jane";
id2 = 0x0000a432;
s = bucketAddItemUnsignedId(pb, &id2, pValSave2);
verify (s == S_bucket_success);
epicsTimeGetCurrent(&start);
for (i=0; i<LOOPS; i++) {
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id1);
verify (pVal == pValSave1);
pVal = bucketLookupItemUnsignedId(pb, &id2);
verify (pVal == pValSave2);
}
epicsTimeGetCurrent(&finish);
duration = epicsTimeDiffInSeconds(&finish, &start);
printf("%d loops took %.10f seconds\n", LOOPS, duration);
duration /= 10 * LOOPS;
printf("which is %.3f nanoseconds per hash lookup\n", duration * 1e9);
bucketShow(pb);
return S_bucket_success;
}