* stress.c: Slightly more verbose output
authorMichael Hampton <io_error@uncensored.citadel.org>
Sun, 25 Jul 2004 16:17:37 +0000 (16:17 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sun, 25 Jul 2004 16:17:37 +0000 (16:17 +0000)
citadel/ChangeLog
citadel/stress.c

index 44e86039b5f4deb7398464c9fcc54f0973247a02..b3a7d85763b39408cb20cd106fb56b44ccb75eda 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 623.8  2004/07/25 16:17:37  error
+ * stress.c:  Slightly more verbose output
+
  Revision 623.7  2004/07/25 16:16:19  error
  * citadel_decls.h: fixed the new logoff() macro
 
@@ -5932,3 +5935,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 6f439381d24127a7acbadeed9f46280b27e8b3a0..7e26c87695c07464aeb793bbc90e8463cdf3addd 100644 (file)
@@ -55,7 +55,9 @@ char* const message =
  *
  * After posting all messages, each thread takes a second timestamp, and
  * subtracts the first timestamp.  The resulting value (in seconds) is
- * sent to standard output.  The thread then exits.
+ * sent to standard output, followed by the minimum, average, and maximum
+ * amounts of time (in milliseconds) it took to post a message.  The
+ * thread then exits.
  *
  * Once all threads have exited, the program exits.
  */
@@ -207,8 +209,6 @@ void* worker(void* data)
                pthread_mutex_unlock(&rand_mutex);
                sleep(wait);
 
-               gettimeofday(&tv, NULL);
-               tstart = tv.tv_sec * 1000 + tv.tv_usec / 1000; /* cvt to msec */
                /* Select the room to goto */
                pthread_mutex_lock(&rand_mutex);
                /* See Numerical Recipes in C or Knuth vol. 2 ch. 3 */
@@ -227,6 +227,8 @@ void* worker(void* data)
                        CtdlIPC_delete_ptr(&ipc);
                        return NULL;
                }
+               gettimeofday(&tv, NULL);
+               tstart = tv.tv_sec * 1000 + tv.tv_usec / 1000; /* cvt to msec */
                r = CtdlIPCGotoRoom(ipc, room, "", &rret, aaa);
                if (r / 100 != 2) {
                        fprintf(stderr, "Citadel refused room change: %s\n", aaa);
@@ -252,7 +254,7 @@ void* worker(void* data)
                pthread_mutex_lock(&count_mutex);
                count++;
                pthread_mutex_unlock(&count_mutex);
-               fprintf(stderr, "%d of %d - %d%%        \r",
+               fprintf(stderr, " %d/%d=%d%%             \r",
                        count, total,
                        (int)(100 * count / total));
                gettimeofday(&tv, NULL);
@@ -264,6 +266,7 @@ void* worker(void* data)
        }
        end = time(NULL);
        pthread_mutex_lock(&output_mutex);
+       fprintf(stderr, "               \r");
        printf("%ld %ld %ld %ld\n", end - start, tmin, trun / c, tmax);
        pthread_mutex_unlock(&output_mutex);
        return (void*)(end - start);
@@ -349,8 +352,8 @@ int main(int argc, char** argv)
                if (i == 0) sleep(3);
        }
 
-       fprintf(stderr, "Starting in 10 seconds\r");
-       sleep(10);
+       fprintf(stderr, "Starting in %d seconds\r", n);
+       sleep(n);
        fprintf(stderr, "                      \r");
 
        /* Then, signal the conditional they all are waiting on */