From 06f0d1d110338b3eb607633583183a076f7d2722 Mon Sep 17 00:00:00 2001 From: alegrand Date: Thu, 31 Mar 2005 01:27:00 +0000 Subject: [PATCH] no more printf (using DEBUG) use of xbt_os_time for benchmarking... git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1205 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- testsuite/surf/maxmin_bench.c | 8 ++++---- testsuite/surf/maxmin_usage.c | 17 +++++++++------- testsuite/surf/surf_usage.c | 37 +++++++++++++++++++---------------- testsuite/surf/surf_usage2.c | 17 +++++++++------- testsuite/surf/trace_usage.c | 7 +++++-- 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/testsuite/surf/maxmin_bench.c b/testsuite/surf/maxmin_bench.c index 08eb1ac6fa..84c10334c6 100644 --- a/testsuite/surf/maxmin_bench.c +++ b/testsuite/surf/maxmin_bench.c @@ -10,7 +10,7 @@ #include #include #include "surf/maxmin.h" -#include "gras/virtu.h" /* time manipulation for benchmarking */ +#include "xbt/sysdep.h" /* time manipulation for benchmarking */ double date; @@ -56,9 +56,9 @@ void test(int nb_cnst, int nb_var, int nb_elem) } } - date = gras_os_time() * 1000000; + date = xbt_os_time() * 1000000; lmm_solve(Sys); - date = gras_os_time() * 1000000 - date; + date = xbt_os_time() * 1000000 - date; lmm_system_free(Sys); free(cnst); @@ -72,7 +72,7 @@ int main(int argc, char **argv) int nb_cnst = 2000; int nb_var = 2000; int nb_elem = 20; - date = gras_os_time() * 1000000; + date = xbt_os_time() * 1000000; test(nb_cnst, nb_var, nb_elem); printf("One shot execution time for a total of %d constraints, " "%d variables with %d active constraint each : %lg microsecondes \n", diff --git a/testsuite/surf/maxmin_usage.c b/testsuite/surf/maxmin_usage.c index 33f3213d29..b206ff505c 100644 --- a/testsuite/surf/maxmin_usage.c +++ b/testsuite/surf/maxmin_usage.c @@ -11,7 +11,10 @@ #include #include "surf/maxmin.h" -#define PRINT_VAR(var) printf(#var " = %lg\n",lmm_variable_getvalue(var)); +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example"); + +#define PRINT_VAR(var) DEBUG1(#var " = %lg\n",lmm_variable_getvalue(var)); /* */ /* ______ */ @@ -57,14 +60,14 @@ void test(void) PRINT_VAR(R_2); PRINT_VAR(R_3); - printf("\n"); + DEBUG0("\n"); lmm_solve(Sys); PRINT_VAR(R_1_2_3); PRINT_VAR(R_1); PRINT_VAR(R_2); PRINT_VAR(R_3); - printf("\n"); + DEBUG0("\n"); lmm_update_variable_weight(Sys,R_1_2_3,.5); @@ -101,22 +104,22 @@ void test2(void) PRINT_VAR(T1); PRINT_VAR(T2); - printf("\n"); + DEBUG0("\n"); lmm_solve(Sys); PRINT_VAR(T1); PRINT_VAR(T2); - printf("\n"); + DEBUG0("\n"); lmm_system_free(Sys); } int main(int argc, char **argv) { - printf("***** Test 1 ***** \n"); + DEBUG0("***** Test 1 ***** \n"); test(); - printf("***** Test 2 ***** \n"); + DEBUG0("***** Test 2 ***** \n"); test2(); return 0; diff --git a/testsuite/surf/surf_usage.c b/testsuite/surf/surf_usage.c index 3222d6a1a3..d7a2749852 100644 --- a/testsuite/surf/surf_usage.c +++ b/testsuite/surf/surf_usage.c @@ -10,6 +10,9 @@ #include #include "surf/surf.h" +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example"); + const char *string_action(e_surf_action_state_t state); const char *string_action(e_surf_action_state_t state) { @@ -50,14 +53,14 @@ void test(char *platform) surf_network_resource_init_CM02(platform); /* Now it is possible to use eth0 */ /*********************** CPU ***********************************/ - printf("%p \n", surf_cpu_resource); + DEBUG1("%p \n", surf_cpu_resource); cpuA = surf_cpu_resource->common_public->name_service("Cpu A"); cpuB = surf_cpu_resource->common_public->name_service("Cpu B"); /* Let's check that those two processors exist */ - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_cpu_resource->common_public->get_resource_name(cpuA), cpuA); - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_cpu_resource->common_public->get_resource_name(cpuB), cpuB); /* Let's do something on it */ @@ -71,20 +74,20 @@ void test(char *platform) stateActionC = surf_cpu_resource->common_public->action_get_state(actionC); /* When you know actionA resource type */ /* And just look at the state of these tasks */ - printf("actionA : %p (%s)\n", actionA, string_action(stateActionA)); - printf("actionB : %p (%s)\n", actionB, string_action(stateActionB)); - printf("actionC : %p (%s)\n", actionB, string_action(stateActionC)); + DEBUG2("actionA : %p (%s)\n", actionA, string_action(stateActionA)); + DEBUG2("actionB : %p (%s)\n", actionB, string_action(stateActionB)); + DEBUG2("actionC : %p (%s)\n", actionB, string_action(stateActionC)); /*********************** Network *******************************/ - printf("%p \n", surf_network_resource); + DEBUG1("%p \n", surf_network_resource); cardA = surf_network_resource->common_public->name_service("Cpu A"); cardB = surf_network_resource->common_public->name_service("Cpu B"); /* Let's check that those two processors exist */ - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_network_resource->common_public->get_resource_name(cardA), cardA); - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_network_resource->common_public->get_resource_name(cardB), cardB); @@ -97,37 +100,37 @@ void test(char *platform) do { surf_action_t action = NULL; now = surf_get_clock(); - printf("Next Event : " "%lg" "\n", now); - printf("\t CPU actions\n"); + DEBUG1("Next Event : " "%lg" "\n", now); + DEBUG0("\t CPU actions\n"); while ((action = xbt_swag_extract(surf_cpu_resource->common_public->states. failed_action_set))) { - printf("\t * Failed : %p\n", action); + DEBUG1("\t * Failed : %p\n", action); action->resource_type->common_public->action_free(action); } while ((action = xbt_swag_extract(surf_cpu_resource->common_public->states. done_action_set))) { - printf("\t * Done : %p\n", action); + DEBUG1("\t * Done : %p\n", action); action->resource_type->common_public->action_free(action); } - printf("\t Network actions\n"); + DEBUG0("\t Network actions\n"); while ((action = xbt_swag_extract(surf_network_resource->common_public->states. failed_action_set))) { - printf("\t * Failed : %p\n", action); + DEBUG1("\t * Failed : %p\n", action); action->resource_type->common_public->action_free(action); } while ((action = xbt_swag_extract(surf_network_resource->common_public->states. done_action_set))) { - printf("\t * Done : %p\n", action); + DEBUG1("\t * Done : %p\n", action); action->resource_type->common_public->action_free(action); } } while (surf_solve()>=0.0); - printf("Simulation Terminated\n"); + DEBUG0("Simulation Terminated\n"); surf_finalize(); } diff --git a/testsuite/surf/surf_usage2.c b/testsuite/surf/surf_usage2.c index a92b72de55..36da616329 100644 --- a/testsuite/surf/surf_usage2.c +++ b/testsuite/surf/surf_usage2.c @@ -10,6 +10,9 @@ #include #include "surf/surf.h" +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example"); + const char *string_action(e_surf_action_state_t state); const char *string_action(e_surf_action_state_t state) { @@ -53,10 +56,10 @@ void test(char *platform) surf_workstation_resource->common_public->name_service("Cpu B"); /* Let's check that those two processors exist */ - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_workstation_resource->common_public-> get_resource_name(workstationA), workstationA); - printf("%s : %p\n", + DEBUG2("%s : %p\n", surf_workstation_resource->common_public-> get_resource_name(workstationB), workstationB); @@ -82,26 +85,26 @@ void test(char *platform) surf_resource_t resource = NULL; now = surf_get_clock(); - printf("Next Event : " "%lg" "\n", now); + DEBUG1("Next Event : " "%lg" "\n", now); xbt_dynar_foreach(resource_list, i, resource) { - printf("\t %s actions\n", resource->common_public->name); + DEBUG1("\t %s actions\n", resource->common_public->name); while ((action = xbt_swag_extract(resource->common_public->states. failed_action_set))) { - printf("\t * Failed : %p\n", action); + DEBUG1("\t * Failed : %p\n", action); resource->common_public->action_free(action); } while ((action = xbt_swag_extract(resource->common_public->states. done_action_set))) { - printf("\t * Done : %p\n", action); + DEBUG1("\t * Done : %p\n", action); resource->common_public->action_free(action); } } } while (surf_solve()>=0.0); - printf("Simulation Terminated\n"); + DEBUG0("Simulation Terminated\n"); surf_finalize(); } diff --git a/testsuite/surf/trace_usage.c b/testsuite/surf/trace_usage.c index 0f2dcdee01..2253e4dfc4 100644 --- a/testsuite/surf/trace_usage.c +++ b/testsuite/surf/trace_usage.c @@ -13,6 +13,9 @@ #include "surf/trace_mgr.h" #include "surf/surf.h" +#include "xbt/log.h" +XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example"); + void test(void); void test(void) { @@ -29,10 +32,10 @@ void test(void) tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B); while ((next_event_date = tmgr_history_next_date(history)) != -1.0) { - printf("%lg" " : \n", next_event_date); + DEBUG1("%lg" " : \n", next_event_date); while (tmgr_history_get_next_event_leq(history, next_event_date, &value, (void **) &resource)) { - printf("\t %s : " "%lg" "\n", resource, value); + DEBUG2("\t %s : " "%lg" "\n", resource, value); } if (next_event_date > 1000) break; -- 2.20.1