diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index 242d28a1c..9d5aa6e37 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -61,6 +61,9 @@ testHarness_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp TESTFILES += $(COMMON_DIR)/arrShorthandTest.dbd TESTS += arrShorthandTest +TESTPROD_HOST += benchdbConvert +benchdbConvert_SRCS += benchdbConvert.c + # The testHarness runs all the test programs in a known working order. testHarness_SRCS += epicsRunDbTests.c diff --git a/src/ioc/db/test/benchdbConvert.c b/src/ioc/db/test/benchdbConvert.c new file mode 100644 index 000000000..cbc87ad24 --- /dev/null +++ b/src/ioc/db/test/benchdbConvert.c @@ -0,0 +1,124 @@ +/*************************************************************************\ +* Copyright (c) 2013 Brookhaven Science Assoc, as Operator of Brookhaven +* National Laboratory. +\*************************************************************************/ +#include "string.h" + +#include "cantProceed.h" +#include "dbAddr.h" +#include "dbConvert.h" +#include "dbDefs.h" +#include "epicsTime.h" +#include "epicsMath.h" +#include "epicsAssert.h" + +#include "epicsUnitTest.h" +#include "testMain.h" + +typedef struct { + size_t nelem, niter; + + short *output; + short *input; + + GETCONVERTFUNC getter; + + DBADDR addr; +} testData; + +static long runRep(testData *D) +{ + size_t i; + + for(i=0; initer; i++) { + D->getter(&D->addr, D->output, D->nelem, D->nelem, 0); + } + return 0; +} + +static void runBench(size_t nelem, size_t niter, size_t nrep) +{ + size_t i; + testData tdat; + double *reptimes; + testDiag("Using %lu element arrays.",(unsigned long)nelem); + testDiag("run %lu reps with %lu iterations each", + (unsigned long)nrep, (unsigned long)niter); + + reptimes = callocMustSucceed(nrep, sizeof(*reptimes), "runBench"); + tdat.output = callocMustSucceed(nelem, sizeof(*tdat.output), "runBench"); + tdat.input = callocMustSucceed(nelem, sizeof(*tdat.input), "runBench"); + + tdat.nelem = nelem; + tdat.niter = niter; + + tdat.getter = dbGetConvertRoutine[DBF_SHORT][DBF_SHORT]; + + memset(&tdat.addr, 0, sizeof(tdat.addr)); + tdat.addr.field_type = DBF_SHORT; + tdat.addr.field_size = nelem*sizeof(*tdat.input); + tdat.addr.no_elements = nelem; + tdat.addr.pfield = (void*)tdat.input; + + for(i=0; i