@@ -28,10 +28,11 @@ int main(int argc, char* argv[])
2828 int maxMsgSize = 100 ; // max size of message to send
2929 int sizeIsRandom = 0 ; // flag set to get a random message size (up to maxMsgSize)
3030 int noOutput = 0 ; // when set, messages are created but not sent
31-
31+ int delay = 0 ; // delay in microseconds between messages
32+
3233 // parse command line parameters
3334 int option;
34- while ((option = getopt (argc, argv, " c:s:rn " )) != -1 ) {
35+ while ((option = getopt (argc, argv, " c:s:rnd: " )) != -1 ) {
3536 switch (option) {
3637 case ' c' :
3738 maxMsgCount = atoi (optarg);
@@ -45,10 +46,13 @@ int main(int argc, char* argv[])
4546 case ' n' :
4647 noOutput = 1 ;
4748 break ;
49+ case ' d' :
50+ delay = atoi (optarg);
51+ break ;
4852 }
4953 }
5054
51- printf (" Generating log messages: maxMsgCount=%d maxMsgSize=%d sizeIsRandom=%d\n " , maxMsgCount, maxMsgSize, sizeIsRandom);
55+ printf (" Generating log messages: maxMsgCount=%d maxMsgSize=%d sizeIsRandom=%d delay=%d \n " , maxMsgCount, maxMsgSize, sizeIsRandom, delay );
5256
5357 char * msgBuffer = (char *)malloc (maxMsgSize + 1 );
5458 if (msgBuffer == nullptr )
@@ -78,6 +82,9 @@ int main(int argc, char* argv[])
7882 theLog.log (" %s" , msgBuffer);
7983 }
8084 msgBuffer[sz] = cBak;
85+ if (delay > 0 ) {
86+ usleep (delay);
87+ }
8188 }
8289 double t = theTimer.getTime ();
8390 printf (" Done in %lf seconds\n " , t);
0 commit comments