From: Art Cancro Date: Mon, 4 Mar 2024 21:13:15 +0000 (-0500) Subject: Made a note to fix a divide-by-zero problem. X-Git-Tag: v999~27 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=65a7033e4687ea08debbacd1d83a9d566c6796ab Made a note to fix a divide-by-zero problem. (ops_completed / (time(NULL) - time_started) I thought my new machine had a problem but it turned out to just be running so fast that "time(NULL) - time_started" really was zero. --- diff --git a/citadel/utils/loadtest.c b/citadel/utils/loadtest.c index 8d4e41b2f..409ebc04e 100644 --- a/citadel/utils/loadtest.c +++ b/citadel/utils/loadtest.c @@ -314,6 +314,7 @@ void *loadtest(void *pointer_to_thread_id) { printf("\033[%d;%dH\033[32m%8ld\033[0m", row, col, ++ops); ++ops_completed; // this is declared "volatile" so we don't need to lock it if (thread_id == 0) { + // FIXME the following line produces a divide by zero error on fast machines --- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ printf("\033[2;55H\033[44m\033[33m\033[1m%ld ops/sec \033[0m", (ops_completed / (time(NULL) - time_started))); } fflush(stdout);