diff options
author | Elias Summermatter <elias.summermatter@seccom.ch> | 2021-04-03 21:07:12 +0200 |
---|---|---|
committer | Elias Summermatter <elias.summermatter@seccom.ch> | 2021-04-03 21:07:12 +0200 |
commit | 7af07d8f4eda46d4104b913450500ebc58333bc0 (patch) | |
tree | 4a2668e168d9092acf93b1a183ba9847b006ac67 /src | |
parent | 0aa89b4d44739ec107470530682c540ca3904701 (diff) | |
download | gnunet-7af07d8f4eda46d4104b913450500ebc58333bc0.tar.gz gnunet-7af07d8f4eda46d4104b913450500ebc58333bc0.zip |
Added forking to perf test
Diffstat (limited to 'src')
-rw-r--r-- | src/setu/gnunet-service-setu.c | 1 | ||||
-rw-r--r-- | src/setu/perf_setu_api.c | 38 |
2 files changed, 18 insertions, 21 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c index 58f3c5198..fcd0e425b 100644 --- a/src/setu/gnunet-service-setu.c +++ b/src/setu/gnunet-service-setu.c | |||
@@ -788,7 +788,6 @@ calculate_perf_rtt() { | |||
788 | */ | 788 | */ |
789 | float factor; | 789 | float factor; |
790 | GNUNET_CONFIGURATION_get_value_float(setu_cfg,"IBF", "BUCKET_NUMBER_FACTOR", &factor); | 790 | GNUNET_CONFIGURATION_get_value_float(setu_cfg,"IBF", "BUCKET_NUMBER_FACTOR", &factor); |
791 | return; | ||
792 | long long num_per_bucket; | 791 | long long num_per_bucket; |
793 | GNUNET_CONFIGURATION_get_value_number(setu_cfg,"IBF", "NUMBER_PER_BUCKET", &num_per_bucket); | 792 | GNUNET_CONFIGURATION_get_value_number(setu_cfg,"IBF", "NUMBER_PER_BUCKET", &num_per_bucket); |
794 | 793 | ||
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 | ||
410 | void *perf_thread() { | 410 | void 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 | ||
422 | static void run_petf_thread(int total_runs) { | 420 | static 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 | ||
437 | static void execute_perf() { | 441 | static 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 | } |