loadtest: pretty display when running with hundreds of threads
authorArt Cancro <ajc@citadel.org>
Fri, 1 Sep 2023 16:10:02 +0000 (16:10 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 1 Sep 2023 16:10:02 +0000 (16:10 +0000)
citadel/utils/loadtest.c

index b376f7d5c0faca27f22ceab22decf0b7f8c6943b..8a71fe0770269e74ea53e34231ccde202d50c24d 100644 (file)
@@ -288,13 +288,15 @@ void do_stuff(int serv_sock) {
        serv_puts(serv_sock, buf);
        serv_gets(serv_sock, buf);
 
-       printf("\033[%d;0H\033[32m%6d\033[0m", 7+serv_sock, serv_sock-3);
-
+       int row = 10 + ((serv_sock-3) % 20);
+       int col = ((serv_sock-3) / 20) * 10;
        long ops = 0;
+       printf("\033[%d;%dH\033[32m--------\033[0m", row, col);
+       fflush(stdout);
+       sleep(1);
        while(1) {
-               //alarm(30);
                perform_random_thing(serv_sock);
-               printf("\033[%d;11H\033[33m%8ld\033[0m", 7+serv_sock, ++ops);
+               printf("\033[%d;%dH\033[33m%8ld\033[0m", row, col, ++ops);
                fflush(stdout);
        }
 }
@@ -341,12 +343,12 @@ int main(int argc, char **argv) {
        int nthreads = 3;
 
        fprintf(stderr, "\033[2J\033[H"
-                       "\033[44m\033[33m\033[1m \033[K\033[0m\n"
-                       "\033[44m\033[33m\033[1m Load testing utility for Citadel \033[K\033[0m\n"
-                       "\033[44m\033[33m\033[1m Copyright (c) 2023 by citadel.org et al.  \033[K\033[0m\n"
+                       "\033[44m\033[33m\033[1m                                                                        \033[K\033[0m\n"
+                       "\033[44m\033[33m\033[1m Load testing utility for Citadel                                       \033[K\033[0m\n"
+                       "\033[44m\033[33m\033[1m Copyright (c) 2023 by citadel.org et al.                               \033[K\033[0m\n"
                        "\033[44m\033[33m\033[1m This program is open source software.  Use, duplication, or disclosure \033[K\033[0m\n"
-                       "\033[44m\033[33m\033[1m is subject to the terms of the GNU General Public license v3. \033[K\033[0m\n"
-                       "\033[44m\033[33m\033[1m \033[K\033[0m\n");
+                       "\033[44m\033[33m\033[1m is subject to the terms of the GNU General Public license v3.          \033[K\033[0m\n"
+                       "\033[44m\033[33m\033[1m                                                                        \033[K\033[0m\n");
 
        // Parse command line
        while ((a = getopt(argc, argv, "h:n:")) != EOF) {
@@ -374,8 +376,6 @@ int main(int argc, char **argv) {
        setup_accounts(serv_sock);
        close(serv_sock);
 
-       printf("\033[8Hthread   num_ops\n------ -----------");
-
        for (a=0; a<(nthreads-1); ++a) {
                pthread_t thread;
                pthread_attr_t attr;