Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not make an expensive call to get_route if it is not needed.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 5 May 2011 15:02:45 +0000 (17:02 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 5 May 2011 15:09:17 +0000 (17:09 +0200)
src/surf/network.c
src/surf/network_gtnets.c

index 7a13932..5c61ee9 100644 (file)
@@ -437,17 +437,19 @@ static void net_update_actions_state(double now, double delta)
                                    action->weight);
     }
 #ifdef HAVE_TRACING
                                    action->weight);
     }
 #ifdef HAVE_TRACING
-    xbt_dynar_t route =
-        global_routing->get_route(action->src_name, action->dst_name);
-    link_CM02_t link;
-    unsigned int i;
-    xbt_dynar_foreach(route, i, link) {
-      TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
-                                      action->generic_action.data,
-                                      (surf_action_t) action,
-                                      lmm_variable_getvalue
-                                      (action->variable), now - delta,
-                                      delta);
+    if (TRACE_is_active()) {
+      xbt_dynar_t route = global_routing->get_route(action->src_name,
+                                                    action->dst_name);
+      link_CM02_t link;
+      unsigned int i;
+      xbt_dynar_foreach(route, i, link) {
+        TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
+                                        action->generic_action.data,
+                                        (surf_action_t) action,
+                                        lmm_variable_getvalue
+                                        (action->variable), now - delta,
+                                        delta);
+      }
     }
 #endif
     if(!lmm_get_number_of_cnst_from_var(network_maxmin_system, action->variable)) {
     }
 #endif
     if(!lmm_get_number_of_cnst_from_var(network_maxmin_system, action->variable)) {
index fa43713..c867d2e 100644 (file)
@@ -271,16 +271,19 @@ static void update_actions_state(double now, double delta)
         trace_sent = action->generic_action.cost;
       }
       // tracing resource utilization
         trace_sent = action->generic_action.cost;
       }
       // tracing resource utilization
-      xbt_dynar_t route = global_routing->get_route(action->src_name, action->dst_name);
-      network_link_GTNETS_t link;
-      unsigned int i;
-      xbt_dynar_foreach(route, i, link) {
-        TRACE_surf_link_set_utilization (link->generic_resource.name,
-            action->generic_action.data,
-            (surf_action_t) action,
-            trace_sent/delta,
-            now-delta,
-            delta);
+      if (TRACE_is_active()) {
+        xbt_dynar_t route = global_routing->get_route(action->src_name,
+                                                      action->dst_name);
+        network_link_GTNETS_t link;
+        unsigned int i;
+        xbt_dynar_foreach(route, i, link) {
+          TRACE_surf_link_set_utilization (link->generic_resource.name,
+                                           action->generic_action.data,
+                                           (surf_action_t) action,
+                                           trace_sent/delta,
+                                           now-delta,
+                                           delta);
+        }
       }
 #endif
 
       }
 #endif