summaryrefslogtreecommitdiff
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
parent0aa89b4d44739ec107470530682c540ca3904701 (diff)
Added forking to perf test
-rw-r--r--src/setu/gnunet-service-setu.c1
-rw-r--r--src/setu/perf_setu_api.c38
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() {
*/
float factor;
GNUNET_CONFIGURATION_get_value_float(setu_cfg,"IBF", "BUCKET_NUMBER_FACTOR", &factor);
- return;
long long num_per_bucket;
GNUNET_CONFIGURATION_get_value_number(setu_cfg,"IBF", "NUMBER_PER_BUCKET", &num_per_bucket);
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,
initRandomSets(450,500,500,32);
}
-void *perf_thread() {
-
- printf("OK\n");
-
+void perf_thread() {
GNUNET_TESTING_service_run("perf_setu_api",
"arm",
"test_setu.conf",
&run,
NULL);
+
}
static void run_petf_thread(int total_runs) {
- int core_count=get_nprocs_conf();
- for(int runs = 0; runs < total_runs; runs += core_count) {
- pthread_t tid[core_count];
+ int core_count = get_nprocs_conf();
+ pid_t child_pid, wpid;
+ int status = 0;
- for (int i = 0; i < core_count; i++) {
- pthread_create(&tid[i], NULL, perf_thread, NULL);
- }
+//Father code (before child processes start)
+ for (int processed = 0; processed < total_runs;) {
+ for (int id = 0; id < core_count; id++) {
- for (int i = 0; i < core_count; i++)
- pthread_join(tid[i], NULL);
- }
+ if(processed >= total_runs) break;
+ if ((child_pid = fork()) == 0) {
+ perf_thread();
+ exit(0);
+ }
+ processed=+1;
+ }
+ while ((wpid = wait(&status)) > 0);
+ }
}
static void execute_perf() {
@@ -481,12 +485,6 @@ main (int argc, char **argv)
GNUNET_log_setup ("perf_setu_api",
"WARNING",
NULL);
-
- GNUNET_TESTING_service_run("perf_setu_api",
- "arm",
- "test_setu.conf",
- &run,
- NULL);
- //execute_perf();
+ execute_perf();
return 0;
}