aboutsummaryrefslogtreecommitdiff
path: root/src/setu/perf_setu_api.c
diff options
context:
space:
mode:
authorElias Summermatter <elias.summermatter@seccom.ch>2021-04-03 21:07:12 +0200
committerElias Summermatter <elias.summermatter@seccom.ch>2021-04-03 21:07:12 +0200
commit7af07d8f4eda46d4104b913450500ebc58333bc0 (patch)
tree4a2668e168d9092acf93b1a183ba9847b006ac67 /src/setu/perf_setu_api.c
parent0aa89b4d44739ec107470530682c540ca3904701 (diff)
downloadgnunet-7af07d8f4eda46d4104b913450500ebc58333bc0.tar.gz
gnunet-7af07d8f4eda46d4104b913450500ebc58333bc0.zip
Added forking to perf test
Diffstat (limited to 'src/setu/perf_setu_api.c')
-rw-r--r--src/setu/perf_setu_api.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/setu/perf_setu_api.c b/src/setu/perf_setu_api.c
index 799462486..2554bad80 100644
--- a/src/setu/perf_setu_api.c
+++ b/src/setu/perf_setu_api.c
@@ -407,31 +407,35 @@ run (void *cls,
407 initRandomSets(450,500,500,32); 407 initRandomSets(450,500,500,32);
408} 408}
409 409
410void *perf_thread() { 410void perf_thread() {
411
412 printf("OK\n");
413
414 GNUNET_TESTING_service_run("perf_setu_api", 411 GNUNET_TESTING_service_run("perf_setu_api",
415 "arm", 412 "arm",
416 "test_setu.conf", 413 "test_setu.conf",
417 &run, 414 &run,
418 NULL); 415 NULL);
416
419} 417}
420 418
421 419
422static void run_petf_thread(int total_runs) { 420static void run_petf_thread(int total_runs) {
423 int core_count=get_nprocs_conf(); 421 int core_count = get_nprocs_conf();
424 for(int runs = 0; runs < total_runs; runs += core_count) { 422 pid_t child_pid, wpid;
425 pthread_t tid[core_count]; 423 int status = 0;
426 424
427 for (int i = 0; i < core_count; i++) { 425//Father code (before child processes start)
428 pthread_create(&tid[i], NULL, perf_thread, NULL); 426 for (int processed = 0; processed < total_runs;) {
429 } 427 for (int id = 0; id < core_count; id++) {
430 428
431 for (int i = 0; i < core_count; i++) 429 if(processed >= total_runs) break;
432 pthread_join(tid[i], NULL);
433 }
434 430
431 if ((child_pid = fork()) == 0) {
432 perf_thread();
433 exit(0);
434 }
435 processed=+1;
436 }
437 while ((wpid = wait(&status)) > 0);
438 }
435} 439}
436 440
437static void execute_perf() { 441static void execute_perf() {
@@ -481,12 +485,6 @@ main (int argc, char **argv)
481 GNUNET_log_setup ("perf_setu_api", 485 GNUNET_log_setup ("perf_setu_api",
482 "WARNING", 486 "WARNING",
483 NULL); 487 NULL);
484 488 execute_perf();
485 GNUNET_TESTING_service_run("perf_setu_api",
486 "arm",
487 "test_setu.conf",
488 &run,
489 NULL);
490 //execute_perf();
491 return 0; 489 return 0;
492} 490}