From e9af650f7b0e1eb307aecd28d81f16c007421237 Mon Sep 17 00:00:00 2001 From: thiery Date: Tue, 8 Aug 2006 09:03:05 +0000 Subject: [PATCH] Don't malloc a new dict each time in execute_parallel_task git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2698 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/workstation.c | 20 +++++++++++--------- src/surf/workstation_KCCFLN05.c | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/surf/workstation.c b/src/surf/workstation.c index 405f8b2711..f8b2760971 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -305,12 +305,18 @@ static surf_action_t execute_parallel_task (int workstation_nb, { surf_action_parallel_task_CSL05_t action = NULL; int i, j, k; - xbt_dict_t network_link_set = xbt_dict_new(); - xbt_dict_cursor_t cursor = NULL; - char *name = NULL; + static xbt_dict_t network_link_set; + static int first_run = 1; int nb_link = 0; int nb_host = 0; - network_link_CM02_t link; + + if (first_run) { + network_link_set = xbt_dict_new_ext(workstation_nb * workstation_nb * 10); + first_run = 0; + } + else { + xbt_dict_reset(network_link_set); + } /* Compute the number of affected resources... */ for(i=0; i< workstation_nb; i++) { @@ -327,11 +333,7 @@ static surf_action_t execute_parallel_task (int workstation_nb, } } - xbt_dict_foreach(network_link_set, cursor, name, link) { - nb_link++; - } - - xbt_dict_free(&network_link_set); + nb_link = xbt_dict_length(network_link_set); for (i = 0; i0) nb_host++; diff --git a/src/surf/workstation_KCCFLN05.c b/src/surf/workstation_KCCFLN05.c index f18b52c317..894ffa3ba3 100644 --- a/src/surf/workstation_KCCFLN05.c +++ b/src/surf/workstation_KCCFLN05.c @@ -557,12 +557,18 @@ static surf_action_t execute_parallel_task(int workstation_nb, { surf_action_workstation_KCCFLN05_t action = NULL; int i, j, k; - xbt_dict_t network_link_set = xbt_dict_new(); - xbt_dict_cursor_t cursor = NULL; - char *name = NULL; + static xbt_dict_t network_link_set; + static int first_run = 1; int nb_link = 0; int nb_host = 0; - network_link_KCCFLN05_t link; + + if (first_run) { + network_link_set = xbt_dict_new_ext(workstation_nb * workstation_nb * 10); + first_run = 0; + } + else { + xbt_dict_reset(network_link_set); + } /* Compute the number of affected resources... */ for(i=0; i< workstation_nb; i++) { @@ -579,11 +585,7 @@ static surf_action_t execute_parallel_task(int workstation_nb, } } - xbt_dict_foreach(network_link_set, cursor, name, link) { - nb_link++; - } - - xbt_dict_free(&network_link_set); + nb_link = xbt_dict_length(network_link_set); for (i = 0; i0) nb_host++; -- 2.20.1