projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5d9dca3
)
loadtest: change display
author
Art Cancro
<ajc@citadel.org>
Mon, 16 Oct 2023 15:59:58 +0000
(06:59 -0900)
committer
Art Cancro
<ajc@citadel.org>
Mon, 16 Oct 2023 15:59:58 +0000
(06:59 -0900)
citadel/utils/loadtest.c
patch
|
blob
|
history
diff --git
a/citadel/utils/loadtest.c
b/citadel/utils/loadtest.c
index 2d62d98ac1a7c96759dc0b2cf313d88971315eb4..5d0e15062a3b510b81c5c62025afdcf490e761b6 100644
(file)
--- a/
citadel/utils/loadtest.c
+++ b/
citadel/utils/loadtest.c
@@
-275,10
+275,19
@@
void perform_random_thing(int serv_sock) {
// This is the main loop. We log in as the load test user, and then perform random operations until stopped.
// This is the main loop. We log in as the load test user, and then perform random operations until stopped.
-void *loadtest(void *
blah
) {
+void *loadtest(void *
ptr
) {
char buf[SIZ];
int serv_sock;
char buf[SIZ];
int serv_sock;
+ // Find a nice spot on the screen to show the operation count for this thread.
+ int threadnum;
+ threadnum = (ptr ? (*(int *)ptr) : 0);
+ int row = 10 + (threadnum % 20);
+ int col = (threadnum / 20) * 10;
+ long ops = 0;
+ printf("\033[%d;%dH\033[33m 0\033[0m", row, col);
+ fflush(stdout);
+
serv_sock = uds_connectsock(file_citadel_socket);
if (serv_sock < 0) {
serv_sock = uds_connectsock(file_citadel_socket);
if (serv_sock < 0) {
@@
-298,12
+307,6
@@
void *loadtest(void *blah) {
serv_puts(serv_sock, buf);
serv_gets(serv_sock, buf);
serv_puts(serv_sock, buf);
serv_gets(serv_sock, buf);
- // Find a nice spot on the screen to show the operation count for this thread.
- int row = 10 + ((serv_sock-3) % 20);
- int col = ((serv_sock-3) / 20) * 10;
- long ops = 0;
- printf("\033[%d;%dH\033[33m 0\033[0m", row, col);
- fflush(stdout);
while(1) {
perform_random_thing(serv_sock);
printf("\033[%d;%dH\033[32m%8ld\033[0m", row, col, ++ops);
while(1) {
perform_random_thing(serv_sock);
printf("\033[%d;%dH\033[32m%8ld\033[0m", row, col, ++ops);
@@
-371,6
+374,14
@@
int main(int argc, char **argv) {
exit(errno);
}
exit(errno);
}
+ // set up the screen
+ for (i=0; i<nthreads; ++i) {
+ int row = 10 + (i % 20);
+ int col = (i / 20) * 10;
+ printf("\033[%d;%dH\033[31m--------\033[0m", row, col);
+ }
+ fflush(stdout);
+
// Generate a random password for load test user. No one needs this password except us.
srand(time(NULL)+getpid());
for (i=0; i<sizeof(test_pass)-1; ++i) {
// Generate a random password for load test user. No one needs this password except us.
srand(time(NULL)+getpid());
for (i=0; i<sizeof(test_pass)-1; ++i) {
@@
-390,25
+401,25
@@
int main(int argc, char **argv) {
setup_accounts(serv_sock);
close(serv_sock);
setup_accounts(serv_sock);
close(serv_sock);
+ // start up load testing threads
for (i=0; i<(nthreads-1); ++i) {
for (i=0; i<(nthreads-1); ++i) {
-
- int row = 10 + ((i+1) % 20);
- int col = ((i+1) / 20) * 10;
- printf("\033[%d;%dH\033[31m--------\033[0m", row, col);
- fflush(stdout);
-
pthread_t thread;
pthread_attr_t attr;
int ret = 0;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstacksize(&attr, THREADSTACKSIZE);
pthread_t thread;
pthread_attr_t attr;
int ret = 0;
ret = pthread_attr_init(&attr);
ret = pthread_attr_setstacksize(&attr, THREADSTACKSIZE);
- ret = pthread_create(&thread, &attr, loadtest,
NULL
);
+ ret = pthread_create(&thread, &attr, loadtest,
&i
);
if (ret != 0) {
exit(ret);
}
}
if (ret != 0) {
exit(ret);
}
}
+
+ // now the original thread becomes load testing thread 0
loadtest(NULL);
loadtest(NULL);
+
+ // should never get here
return(0);
return(0);
-}
\ No newline at end of file
+}
+