From 8223eba81b3ae1065316afe9b9274f5a51893a45 Mon Sep 17 00:00:00 2001 From: fanasina Date: Tue, 7 Apr 2026 23:40:34 +0200 Subject: [PATCH] [update] ftest : add omp and omp_get_wtime --- y_test_h.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/y_test_h.h b/y_test_h.h index eee47e2..21bc332 100644 --- a/y_test_h.h +++ b/y_test_h.h @@ -208,6 +208,7 @@ void bar_progress_stop(void); //#include #include /* to have size of screen, for progress bar */ +#include #define DEFAULT_K "\033[0m" /*Resets the text to default color*/ #define GREEN_K "\033[0;32m" @@ -2629,9 +2630,9 @@ bool expected_array_##OP##_name_##type(type *var1, long int sz1, type *var2, lon #define PRINT_TIMESTAMP_STAT(color)\ - if(SECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf s)\n\n",count_pass_local,fun_ame, diff_timespec_seconds(end_t, start_t));\ - else if(NANOSECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%ld ns)\n\n",count_pass_local,fun_ame, diff_timespec_nanoseconds(end_t, start_t));\ - else PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf ms)\n\n",count_pass_local,fun_ame, diff_timespec_milliseconds(end_t, start_t)); + if(SECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf s) [bench omp:%lf s]\n\n",count_pass_local,fun_ame, diff_timespec_seconds(end_t, start_t),end_d-start_d);\ + else if(NANOSECOND) PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%ld ns) [bench omp:%lf s]\n\n",count_pass_local,fun_ame, diff_timespec_nanoseconds(end_t, start_t),end_d-start_d);\ + else PRINT_HK_C(color,tab_hk_f[hk_DN]," %lu tests passed from %s (%lf ms) [bench omp:%lf s]\n\n",count_pass_local,fun_ame, diff_timespec_milliseconds(end_t, start_t),end_d-start_d);\ /* * need to separate num type and ptr type because of (void*) @@ -3378,15 +3379,17 @@ append_func(void (*run)(void), char *name){ \ ++count_tests; \ } \ \ -void begin_execute_func(char *fun_ame, struct timespec *start_t){ \ +void begin_execute_func(char *fun_ame, struct timespec *start_t, double *start_d){ \ clock_gettime(CLOCK_REALTIME, start_t); \ + *start_d = omp_get_wtime();\ PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_RN]," %s\n", fun_ame); \ count_pass_local = 0; \ count_fail_local = 0; \ } \ \ -void end_execute_func(char *fun_ame, struct timespec start_t){ \ +void end_execute_func(char *fun_ame, struct timespec start_t, double start_d){ \ struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t); \ + double end_d = omp_get_wtime();\ if(count_fail_local){ \ INCREMENT(count_fail_global); /*++count_fail_global*/ \ append_failed_list(&failed_l, fun_ame); \ @@ -3459,6 +3462,7 @@ void extract_name_test_from_name(char *name_org, char **name_f){ \ void execute_all(struct func *fun){ \ struct func *tmp = fun; \ struct timespec start_t; \ + double start_d;\ size_t num_f; \ char *name_test=NULL; \ bool exec_test=0; \ @@ -3471,9 +3475,9 @@ void execute_all(struct func *fun){ \ current_fn = tmp; \ CHECK_IF_SELECTED_TEST(tmp->name) \ if(exec_test){ \ - begin_execute_func(tmp->name, &start_t); \ + begin_execute_func(tmp->name, &start_t, &start_d); \ tmp->run(); \ - end_execute_func(tmp->name, start_t); \ + end_execute_func(tmp->name, start_t, start_d); \ } \ tmp = tmp->next; \ } \ @@ -3570,13 +3574,15 @@ stat_end_all_parallel_run(size_t ntst, struct timespec start_t){ \ \ \ \ -void begin_execute_func_parallel(char *fun_ame, struct timespec *start_t, size_t id_thrd){ \ +void begin_execute_func_parallel(char *fun_ame, struct timespec *start_t, size_t id_thrd, double *start_d){ \ clock_gettime(CLOCK_REALTIME, start_t); \ + *start_d = omp_get_wtime();\ PRINT_HK_C(colors_f[k_GREEN],tab_hk_f[hk_RN]," %s on thread[%ld]\n", fun_ame, id_thrd); \ } \ \ -void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id_thrd){ \ +void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id_thrd, double start_d){ \ struct timespec end_t; clock_gettime(CLOCK_REALTIME, &end_t); \ + double end_d = omp_get_wtime();\ size_t num_test = extract_num__f(fun_ame); \ PRINT_DEBUG(" ... thread[%ld], count_fail_test[%ld] = %ld ... %s\n", id_thrd, num_test, count_fail_test[num_test],fun_ame); \ if(count_fail_test[num_test]){ \ @@ -3600,6 +3606,7 @@ void end_execute_func_parallel(char *fun_ame, struct timespec start_t, size_t id void execute_test_parallel(size_t id_thrd){ \ \ struct timespec start_t; \ + double start_d;\ struct func *tmp; \ size_t num_f; \ char *name_test=NULL; \ @@ -3618,9 +3625,9 @@ void execute_test_parallel(size_t id_thrd){ \ CHECK_IF_SELECTED_TEST(tmp->name) \ if(exec_test){ \ PRINT_DEBUG(" *** thread[%ld], func_name = %s *** \n", id_thrd, tmp->name); \ - begin_execute_func_parallel(tmp->name, &start_t, id_thrd); \ + begin_execute_func_parallel(tmp->name, &start_t, id_thrd, &start_d); \ tmp->run(); \ - end_execute_func_parallel(tmp->name, start_t, id_thrd); \ + end_execute_func_parallel(tmp->name, start_t, id_thrd, start_d); \ } \ } \ else{ \