cdev-1.7.2n

This commit is contained in:
2022-12-13 12:44:04 +01:00
commit b3b88fc333
1357 changed files with 338883 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
ARCH = OS
SHOBJ = YES
include ../../include/makeinclude/Makefile.$(ARCH)
APPNAME = "Performance Client/Server Test"
CXXINCLUDES = -I./ -DMANUAL=TRUE
SO_SRCS = PerformanceService.cc
SO_LIBS = -L$(CDEVLIB) -lcdevGenericServer $(OSLIBS)
LIBS = -L$(CDEVLIB) -lcdevGenericServer $(CDEVLIBS) $(OSLIBS)
ifeq ($(SHOBJ), YES)
TARGETS = $(BASELIB)/PerformanceService.so $(BASEBIN)/PerformanceServer $(BASEBIN)/PerformanceTest $(BASEBIN)/PerformanceTest2
else
TARGETS = $(BASELIB)/libPerformanceService.a $(BASEBIN)/PerformanceServer $(BASEBIN)/PerformanceTest $(BASEBIN)/PerformanceTest2
endif
targets : $(TARGETS)
$(BASEBIN)/PerformanceTest : $(OBJDIR)/PerformanceTest.o
$(LINK.cc) $^ $(LIBS) -o $@
$(BASEBIN)/PerformanceTest2 : $(OBJDIR)/PerformanceTest2.o
$(LINK.cc) $^ $(LIBS) -o $@
$(BASEBIN)/PerformanceServer : $(OBJDIR)/PerformanceServer.o
$(LINK.cc) $^ $(LIBS) -o $@
$(BASELIB)/PerformanceService.so : $(OBJDIR)/PerformanceService.o
$(LINK.so) -o $@ $^ -L$(CDEVLIB) -lcdevGenericServer $(OSLIBS)
@mkdir -p $(CDEVSHOBJ)/$(CDEVVERSION)
@cp $@ $(CDEVSHOBJ)/$(CDEVVERSION)/$(@F)
$(BASELIB)/libPerformanceService.a : $(OBJDIR)/PerformanceService.o
$(LINK.a) $@ $(OBJDIR)/PerformanceService.o
@$(RANLIB) $@ > /dev/null
@@ -0,0 +1,59 @@
.SUFFIXES: .cc .obj
APPNAME = Client/Server Performance Test
ARCH = WINNT-4.0
SHOBJ = YES
BINARIES = $(BASEBIN)\PerformanceServer.exe \
$(BASEBIN)\PerformanceTest.exe \
$(CDEVLIB)\PerformanceService.dll \
$(CDEVLIB)\PerformanceService.lib
include ..\..\include\makeinclude\Makefile.WINNT-4.0
CXXINCLUDES = /I .\\ /D "MANUAL=TRUE"
CXXEXTRA_DLL = /D "PERFORMANCE_SERVICE_API=__declspec(dllexport)"
CXXEXTRA_LIB = /D "PERFORMANCE_SERVICE_API="
!IF "$(SHOBJ)" == "YES"
TARGETS = $(BASEBIN)\PerformanceServer.exe \
$(BASEBIN)\PerformanceTest.exe \
$(CDEVLIB)\PerformanceService.dll
!ELSE
TARGETS = $(BASEBIN)\PerformanceServer.exe \
$(BASEBIN)\PerformanceTest.exe \
$(CDEVLIB)\PerformanceService.lib
!ENDIF
targets : $(TARGETS)
$(CDEVLIB)\PerformanceService.dll : $(OBJDIR)\PerformanceService.obj
@echo ^ ^ ^ =^> Linking $(@F)
-@if exist $@ erase $@
-@if not exist $(@D) mkdir $(@D)
@$(LIB32) $(CDEVLIB)\cdev.lib $(CDEVLIB)\cdevGenericServer.lib\
$(LINK_DLL_FLAGS) /out:$@ /implib:$(@D)\$(@B).lib $?
-@copy $@ $(CDEVSHOBJ)\$(CDEVVERSION)\$(@F) > nul
@echo ^ ^ ^ ^ ^ ^ Done...
$(CDEVLIB)\PerformanceService.lib : $(OBJDIR)\PerformanceService.obj
@echo ^ ^ ^ =^> Linking $(@F)
-@if exist $@ erase $@
-@if not exist $(@D) mkdir $(@D)
@$(LIB32) $(CDEVLIB)\cdev.lib $(CDEVLIB)\cdevGenericServer.lib\
$(LINK_LIB_FLAGS) /out:$@ $?
@echo ^ ^ ^ ^ ^ ^ Done...
$(BASEBIN)\PerformanceServer.exe : .exec\$(TARGETDIR)\PerformanceServer.obj
-@if exist $@ erase $@
@echo ^ ^ ^ ^ ^ ^ =^> Linking $(@F)
$(LINK) $(CDEVLIB)\cdev.lib $(CDEVLIB)\cdevGenericServer.lib \
$(LINK_EXE_FLAGS) /out:$@ $?
@echo ^ ^ ^ ^ ^ ^ ^ ^ ^ Done...
$(BASEBIN)\PerformanceTest.exe : .exec\$(TARGETDIR)\PerformanceTest.obj
-@if exist $@ erase $@
@echo ^ ^ ^ ^ ^ ^ =^> Linking $(@F)
$(LINK) $(CDEVLIB)\cdev.lib $(CDEVLIB)\cdevGenericServer.lib \
$(LINK_EXE_FLAGS) /out:$@ $?
@echo ^ ^ ^ ^ ^ ^ ^ ^ ^ Done...
@@ -0,0 +1,26 @@
service Performance
{
tags {server}
}
class Performances
{
verbs {get, set}
attributes
{
default Performance;
servers Performance;
attrib0 Performance {server=Performance1};
attrib1 Performance {server=Performance1};
}
messages
{
disconnect Performance;
}
}
Performances :
device0;
alias device1 device0
@@ -0,0 +1,51 @@
#include <cdevServer.h>
// *****************************************************************************
// * class PerformanceServer :
// * This is a performance test server. It simply receives messages
// * from a client and immediately returns them.
// *
// * The constructor passes the domain, server, port and rate to the
// * underlying cdevServer class to be processed. The cdevServer constructor
// * will add this server to the Name Server and will begin processing
// * messages when the cdevServer::runServer() method is executed.
// *
// * The processMessages method is the servers interface to the world... Each
// * time a complete message is received or the time specified in rate
// * expires, that method will be called.
// *****************************************************************************
class PerformanceServer : public cdevServer
{
cdevMessage * pmMessage;
public:
PerformanceServer ( char * domain, char * server, unsigned int port, double pulse )
: cdevServer(domain, server, port, pulse)
{
}
virtual void processMessages ( void )
{
while(dequeue(pmMessage)==0)
{
enqueue(pmMessage);
delete pmMessage;
}
}
};
int main(int argc, char ** argv)
{
char * serverName;
if(argc>1) serverName = argv[1];
else serverName = strdup("Performance1");
PerformanceServer server("PERFORMANCE", serverName, 0, 5);
cdevServer::runServer();
return 0;
}
@@ -0,0 +1,28 @@
#include <PerformanceService.h>
// *****************************************************************************
// * newPerformanceService:
// * This function will be called by the cdevSystem object to create an
// * initial instance of the PerformanceService.
// *****************************************************************************
extern "C" cdevService * newPerformanceService (char * name, cdevSystem * system)
{
return new PerformanceService(name, *system);
}
// *****************************************************************************
// * PerformanceService::PerformanceService :
// * This is teh constructor for the PerformanceService. It initializes the
// * underlying cdevClientService by specifying that it is in the domain of
// * PERFORMANCE.
// *****************************************************************************
PerformanceService::PerformanceService ( char * name, cdevSystem & system)
: cdevClientService("PERFORMANCE", name, system)
{
system.reportError(CDEV_SEVERITY_INFO, "PerformanceService", NULL,
"Constructing a new PerformanceService");
}
PerformanceService::~PerformanceService ( void )
{
}
@@ -0,0 +1,27 @@
#include <cdevClientService.h>
#ifndef PERFORMANCE_SERVICE_API
#define PERFORMANCE_SERVICE_API
#endif
// *****************************************************************************
// * newPerformanceService :
// * This function will be called by the cdevSystem object to create an
// * initial instance of the PerformanceService.
// *****************************************************************************
extern "C" PERFORMANCE_SERVICE_API cdevService * newPerformanceService ( char * name, cdevSystem * system );
// *****************************************************************************
// * class PerformanceService :
// * This class simply inherits from the cdevClientService and must define
// * only a constructor and destructor.
// *****************************************************************************
class PerformanceService : public cdevClientService
{
public:
PerformanceService ( char * name, cdevSystem & system = cdevSystem::defaultSystem());
protected:
~PerformanceService ( void );
};
@@ -0,0 +1,383 @@
#include <cdevPlatforms.h>
#include <cdevSystem.h>
#include <cdevRequestObject.h>
#include <cdevDevice.h>
#include <cdevGroup.h>
#include <cdevCommon.h>
#include <cdevMessage.h>
struct timeval first;
int callbackCount = 0;
int reportCount = 0;
int reportFrequency = 0;
int bunchSize = 0;
char * deviceName = "device0";
char * messageStr = "set attrib0";
double PerformanceRate = 0.0;
double * performanceRatePtr = &PerformanceRate;
size_t PacketSize = 0;
size_t * packetSizePtr = &PacketSize;
int synchroValue = 0;
int synchroFound = 0;
void synchroCallback (int status, void *, cdevRequestObject &, cdevData & data)
{
if(status==CDEV_SUCCESS)
{
int value;
data.get("value", &value);
if(value==synchroValue) synchroFound = 1;
}
}
void callback ( int status, void *, cdevRequestObject &, cdevData & )
{
if(status==CDEV_SUCCESS)
{
callbackCount++;
reportCount++;
if(reportCount==reportFrequency)
{
reportCount = 0;
struct timeval second, lapsed;
gettimeofday(&second);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
if(lapsed.tv_sec)
{
*performanceRatePtr = (double)callbackCount/(double)lapsed.tv_sec;
fprintf(stdout, "Average rate is %lf pkts/sec after %ld packets\n", *performanceRatePtr, callbackCount);
}
fflush(stdout);
}
}
}
cdevData * createPayload1 ( int )
{
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return NULL;
}
cdevData * createPayload2 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
int * x = new int[cnt];
for(int i=0; i<cnt; i++) x[i] = (int)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", 1);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload3 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
float * x = new float[cnt];
for(int i=0; i<cnt; i++) x[i] = (float)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", (float)1.0);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload4 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
double * x = new double[cnt];
for(int i=0; i<cnt; i++) x[i] = (double)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", (double)1.0);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload5 ( int cnt )
{
cdevData * data = new cdevData;
char buf[64];
if(cnt>1)
{
char ** x = new char *[cnt];
int i;
for(i=0; i<cnt; i++)
{
sprintf(buf, "This is string %i", i);
x[i] = strdup(buf);
}
data->insert("value", x, cnt);
for(i=0; i<cnt; i++)
{
free(x[i]);
}
delete x;
}
else
{
sprintf(buf, "This is string 0");
data->insert("value", buf);
}
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
const int payloadCount = 10;
char * payloadType[payloadCount] =
{
"None",
"1 - Barebones cdevMessage",
"2 - cdevMessage with one integer value",
"3 - cdevMessage with one float value",
"4 - cdevMessage with one double value",
"5 - cdevMessage with a character string",
"6 - cdevMessage with an array of integers",
"7 - cdevMessage with an array of floats",
"8 - cdevMessage with an array of doubles",
"9 - cdevMessage with an array of strings"
};
typedef cdevData * (*PayloadFunc)(int cnt);
PayloadFunc payloadFunc[payloadCount] =
{
NULL,
createPayload1,
createPayload2,
createPayload3,
createPayload4,
createPayload5,
createPayload2,
createPayload3,
createPayload4,
createPayload5
};
int main ( int argc, char ** argv )
{
int i;
int payload = 0;
int payloadItems = 0;
int count = -1;
if(argc>1) for(i=1; i<argc; i++)
{
if(*argv[i]!='-') goto QUIT_LABEL;
else {
if((i+1)>=argc) goto QUIT_LABEL;
switch (argv[i][1])
{
case 'd': // (d)evice
deviceName = strdup(argv[++i]);
break;
case 'm': // (m)essage
messageStr = strdup(argv[++i]);
break;
case 't': // payload (t)ype
payload = atoi(argv[++i]);
break;
case 'e': // payload (e)lements
payloadItems = atoi(argv[++i]);
break;
case 'b': // (b)unch size
bunchSize = atoi(argv[++i]);
break;
case 'f': // report (f)requency
reportFrequency = atoi(argv[++i]);
break;
case 'c': // packet (c)ount
count = atoi(argv[++i]);
break;
case 'h':
default:
QUIT_LABEL:
printf("\nFormat is: PerformanceTest -d dev -m msg -t type -e elements -b bunch -f freq -c count\n");
printf(" -d dev ... where dev is the name of the cdev device\n");
printf(" -m msg ... where msg is the cdev message string\n");
printf(" -t type ... where type is the outbound data's payload type\n");
for(int x=1; x<payloadCount; x++)
{
printf(" %s\n", payloadType[x]);
}
printf(" -e elements ... where elements is the number of array elements\n");
printf(" -b bunch ... where bunch is the number to send before waiting\n");
printf(" -f freq ... where freq is the report frequency\n");
printf(" -c count ... where count is the number of messages to send\n\n");
fflush(stdout);
return 0;
}
}
}
cdevCallback sb(synchroCallback, NULL);
cdevCallback cb(callback, NULL);
cdevData * data = NULL;
cdevData syncData;
if(payload<1 || payload>=payloadCount)
{
fprintf(stdout, "Payload type specifies the type of data that will\n");
fprintf(stdout, "transmitted in each message...\n");
for(i=1; i<payloadCount; i++)
{
fprintf(stdout, " %s\n", payloadType[i]);
}
fprintf(stdout, "\n");
while(payload<1 || payload>=payloadCount)
{
fprintf(stdout, "Enter payload type (1 - %i): ", payloadCount-1);
fscanf (stdin, "%ld", &payload);
}
}
if(payload>5)
{
if(payloadItems<1)
{
for(payloadItems = 0; payloadItems<1; )
{
fprintf(stdout, "Enter the number of array elements: ");
fscanf(stdin, "%ld", &payloadItems);
}
}
}
else payloadItems = 1;
data = payloadFunc[payload](payloadItems);
if(bunchSize<1 || bunchSize>500)
{
fprintf(stdout, "\nBunch size is the number of packets that will be\n");
fprintf(stdout, "transmitted TO the server before the application\n");
fprintf(stdout, "pauses to listen for replies FROM the server.\n\n");
while(bunchSize<1 || bunchSize>500)
{
fprintf(stdout, "Enter bunch size (1-500): ");
fscanf (stdin, "%ld", &bunchSize);
}
}
if(reportFrequency<1)
{
fprintf(stdout, "\nReport frequency is the number of packets that\n");
fprintf(stdout, "should be received from the server before the application\n");
fprintf(stdout, "pauses to calculate and report performance information.\n\n");
while(reportFrequency<1)
{
fprintf(stdout, "Enter report frequency (1 - Infinity): ");
fscanf (stdin, "%ld", &reportFrequency);
}
}
fprintf(stdout, "\nStarting Test:\n=> Device : %s\n=> Message : %s\n=> Payload : %s\n=> Packet size : %ld\n=> Bunch size : %ld\n=> Frequency : %ld\n", deviceName, messageStr, payloadType[payload], *packetSizePtr, bunchSize, reportFrequency);
if(payloadItems>1) fprintf(stdout, "=> Array Size : %ld\n", payloadItems);
if(count>0) fprintf(stdout, "=> Test Length : %ld Packets\n", count);
cdevRequestObject & req = cdevRequestObject::attachRef(deviceName, messageStr);
if(req.send(NULL, NULL)!=CDEV_SUCCESS)
{
fprintf(stdout, "\nPerformanceTest Error: Request %s %s appears to be invalid\nExiting...\n\n", deviceName, messageStr);
fflush(stdout);
return 0;
}
gettimeofday(&first);
int sendCount = 0;
cdevData recvData;
while(count<0 || sendCount<count )
{
if(bunchSize==1)
{
callback(req.send(data, recvData), NULL, req, recvData);
sendCount++;
}
else {
for(i=0; i<bunchSize; i++)
{
req.sendCallback(data, cb);
sendCount++;
}
int dryPollCount = 1;
do {
if(dryPollCount>1000)
{
fprintf(stdout, "Attempting to resynchronize after polling timeout (%i)\n", dryPollCount);
fflush (stdout);
}
synchroFound = 0;
synchroValue++;
syncData.insert("value", synchroValue);
req.sendCallback(syncData, sb);
while(!synchroFound && dryPollCount%10!=0)
{
if(cdevSystem::defaultSystem().poll()<=0) dryPollCount++;
else dryPollCount=0;
}
dryPollCount++;
} while(!synchroFound);
}
}
return 0;
}
@@ -0,0 +1,347 @@
#include <cdevPlatforms.h>
#include <cdevSystem.h>
#include <cdevRequestObject.h>
#include <cdevDevice.h>
#include <cdevGroup.h>
#include <cdevCommon.h>
#include <cdevMessage.h>
void callback ( int status, void *, cdevRequestObject & req, cdevData & data );
struct timeval first;
int testLength = 0x0FFFFFFF;
int callbackCount = 0;
int reportCount = 0;
int reportFrequency = 0;
int bunchSize = 0;
char * deviceName = "device0";
char * messageStr = "set attrib0";
double PerformanceRate = 0.0;
double * performanceRatePtr = &PerformanceRate;
size_t PacketSize = 0;
size_t * packetSizePtr = &PacketSize;
cdevCallback cb(callback, NULL);
void callback ( int status, void *, cdevRequestObject & req, cdevData & data )
{
if(status==CDEV_SUCCESS)
{
callbackCount++;
reportCount++;
if(reportCount==reportFrequency)
{
reportCount = 0;
struct timeval second, lapsed;
gettimeofday(&second);
if (first.tv_usec > second.tv_usec)
{
second.tv_usec += 1000000;
second.tv_sec--;
}
lapsed.tv_usec = second.tv_usec - first.tv_usec;
lapsed.tv_sec = second.tv_sec - first.tv_sec;
if(lapsed.tv_sec)
{
*performanceRatePtr = (double)callbackCount/(double)lapsed.tv_sec;
fprintf(stdout, "Average rate is %lf pkts/sec after %ld packets\n", *performanceRatePtr, callbackCount);
}
fflush(stdout);
if(callbackCount>=testLength)
{
exit(0);
}
}
req.sendCallback(data, cb);
}
}
cdevData * createPayload1 ( int )
{
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return NULL;
}
cdevData * createPayload2 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
int * x = new int[cnt];
for(int i=0; i<cnt; i++) x[i] = (int)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", 1);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload3 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
float * x = new float[cnt];
for(int i=0; i<cnt; i++) x[i] = (float)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", (float)1.0);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload4 ( int cnt )
{
cdevData * data = new cdevData;
if(cnt>1)
{
double * x = new double[cnt];
for(int i=0; i<cnt; i++) x[i] = (double)i;
data->insert("value", x, cnt);
delete x;
}
else data->insert("value", (double)1.0);
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
cdevData * createPayload5 ( int cnt )
{
cdevData * data = new cdevData;
char buf[64];
if(cnt>1)
{
char ** x = new char *[cnt];
int i;
for(i=0; i<cnt; i++)
{
sprintf(buf, "This is string %i", i);
x[i] = strdup(buf);
}
data->insert("value", x, cnt);
for(i=0; i<cnt; i++)
{
free(x[i]);
}
delete x;
}
else
{
sprintf(buf, "This is string 0");
data->insert("value", buf);
}
char * binary = 0;
cdevMessage msg(1, 1, 0, 0, 0, 0, 0, 1, &deviceName, messageStr, data);
msg.streamOut(&binary, packetSizePtr);
delete binary;
return data;
}
const int payloadCount = 10;
char * payloadType[payloadCount] =
{
"None",
"1 - Barebones cdevMessage",
"2 - cdevMessage with one integer value",
"3 - cdevMessage with one float value",
"4 - cdevMessage with one double value",
"5 - cdevMessage with a character string",
"6 - cdevMessage with an array of integers",
"7 - cdevMessage with an array of floats",
"8 - cdevMessage with an array of doubles",
"9 - cdevMessage with an array of strings"
};
typedef cdevData * (*PayloadFunc)(int cnt);
PayloadFunc payloadFunc[payloadCount] =
{
NULL,
createPayload1,
createPayload2,
createPayload3,
createPayload4,
createPayload5,
createPayload2,
createPayload3,
createPayload4,
createPayload5
};
int main ( int argc, char ** argv )
{
int i;
int payload = 0;
int payloadItems = 0;
if(argc>1) for(i=1; i<argc; i++)
{
if(*argv[i]!='-') goto QUIT_LABEL;
else {
if((i+1)>=argc) goto QUIT_LABEL;
switch (argv[i][1])
{
case 'd': // (d)evice
deviceName = strdup(argv[++i]);
break;
case 'm': // (m)essage
messageStr = strdup(argv[++i]);
break;
case 't': // payload (t)ype
payload = atoi(argv[++i]);
break;
case 'e': // payload (e)lements
payloadItems = atoi(argv[++i]);
break;
case 'b': // (b)unch size
bunchSize = atoi(argv[++i]);
break;
case 'f': // report (f)requency
reportFrequency = atoi(argv[++i]);
break;
case 'c': // packet (c)ount
testLength = atoi(argv[++i]);
break;
case 'h':
default:
QUIT_LABEL:
printf("\nFormat is: PerformanceTest -d dev -m msg -t type -e elements -b bunch -f freq -c count\n");
printf(" -d dev ... where dev is the name of the cdev device\n");
printf(" -m msg ... where msg is the cdev message string\n");
printf(" -t type ... where type is the outbound data's payload type\n");
for(int x=1; x<payloadCount; x++)
{
printf(" %s\n", payloadType[x]);
}
printf(" -e elements ... where elements is the number of array elements\n");
printf(" -b bunch ... where bunch is the number to send before waiting\n");
printf(" -f freq ... where freq is the report frequency\n");
printf(" -c count ... where count is the number of messages to send\n\n");
fflush(stdout);
return 0;
}
}
}
cdevData * data = NULL;
if(payload<1 || payload>=payloadCount)
{
fprintf(stdout, "Payload type specifies the type of data that will\n");
fprintf(stdout, "transmitted in each message...\n");
for(i=1; i<payloadCount; i++)
{
fprintf(stdout, " %s\n", payloadType[i]);
}
fprintf(stdout, "\n");
while(payload<1 || payload>=payloadCount)
{
fprintf(stdout, "Enter payload type (1 - %i): ", payloadCount-1);
fscanf (stdin, "%ld", &payload);
}
}
if(payload>5)
{
if(payloadItems<1)
{
for(payloadItems = 0; payloadItems<1; )
{
fprintf(stdout, "Enter the number of array elements: ");
fscanf(stdin, "%ld", &payloadItems);
}
}
}
else payloadItems = 1;
data = payloadFunc[payload](payloadItems);
if(bunchSize<1 || bunchSize>500)
{
fprintf(stdout, "\nBunch size is the number of packets that will be\n");
fprintf(stdout, "transmitted TO the server before the application\n");
fprintf(stdout, "pauses to listen for replies FROM the server.\n\n");
while(bunchSize<1 || bunchSize>500)
{
fprintf(stdout, "Enter bunch size (1-500): ");
fscanf (stdin, "%ld", &bunchSize);
}
}
if(reportFrequency<1)
{
fprintf(stdout, "\nReport frequency is the number of packets that\n");
fprintf(stdout, "should be received from the server before the application\n");
fprintf(stdout, "pauses to calculate and report performance information.\n\n");
while(reportFrequency<1)
{
fprintf(stdout, "Enter report frequency (1 - Infinity): ");
fscanf (stdin, "%ld", &reportFrequency);
}
}
fprintf(stdout, "\nStarting Test:\n=> Device : %s\n=> Message : %s\n=> Payload : %s\n=> Packet size : %ld\n=> Bunch size : %ld\n=> Frequency : %ld\n", deviceName, messageStr, payloadType[payload], *packetSizePtr, bunchSize, reportFrequency);
if(payloadItems>1) fprintf(stdout, "=> Array Size : %ld\n", payloadItems);
fprintf(stdout, "=> Test Length : %ld Packets\n", testLength);
cdevRequestObject & req = cdevRequestObject::attachRef(deviceName, messageStr);
if(req.send(NULL, NULL)!=CDEV_SUCCESS)
{
fprintf(stdout, "\nPerformanceTest Error: Request %s %s appears to be invalid\nExiting...\n\n", deviceName, messageStr);
fflush(stdout);
return 0;
}
gettimeofday(&first);
for(i=0; i<bunchSize; i++) req.sendCallback(data, cb);
while( 1 )
{
cdevSystem::defaultSystem().pend(10.0);
}
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
#! /bin/tcsh
setenv CDEVDDL ${PWD}/Performance.ddl
if ( $?CDEV_NAME_SERVER == 0 ) then
echo '/nCDEV_NAME_SERVER must be specified/n'
exit
endif
if ( $?CDEV_ARCH == 0 ) then
echo '/nCDEV_ARCH must be specified (Linux, ${CDEV_ARCH}, hpux-10.20, ...)/n'
exit
endif
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 262144 -b 10 -f 50 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 65536 -b 10 -f 50 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 32768 -b 10 -f 50 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 16384 -b 10 -f 50 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 8192 -b 50 -f 50 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 4096 -b 100 -f 100 -c 1000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 1024 -b 500 -f 500 -c 3000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 256 -b 500 -f 1000 -c 10000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 6 -e 64 -b 500 -f 4000 -c 40000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 2 -e 1 -b 500 -f 10000 -c 100000
../../bin/${CDEV_ARCH}/PerformanceTest2 -d device0 -m "set attrib0" -t 1 -e 1 -b 500 -f 10000 -c 100000
@@ -0,0 +1,12 @@
@echo off
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 1 -e 1 -b 500 -f 100000 -c 100000
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 2 -e 1 -b 500 -f 100000 -c 100000
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 64 -b 500 -f 40000 -c 40000
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 256 -b 500 -f 11000 -c 11000
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 1024 -b 500 -f 3000 -c 3000
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 4096 -b 100 -f 800 -c 800
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 8192 -b 50 -f 400 -c 400
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 16384 -b 1 -f 200 -c 200
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 32768 -b 1 -f 100 -c 100
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 65536 -b 1 -f 50 -c 50
..\..\bin\WINNT-4.0\PerformanceTest -d device0 -m "set attrib0" -t 6 -e 262144 -b 1 -f 12 -c 12