Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleaning the actor twice seems somewhat overplayed
[simgrid.git] / src / instr / instr_resource_utilization.cpp
1 /* Copyright (c) 2010-2019. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "src/instr/instr_private.hpp"
8 #include <string>
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorized resource utilization");
11
12 void TRACE_surf_resource_set_utilization(const char* type, const char* name, const char* resource,
13                                          const std::string& category, double value, double now, double delta)
14 {
15   // only trace resource utilization if resource is known by tracing mechanism
16   container_t container = simgrid::instr::Container::by_name_or_null(resource);
17   if (not container || not value)
18     return;
19
20   // trace uncategorized resource utilization
21   if (TRACE_uncategorized()){
22     XBT_DEBUG("UNCAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, name, value);
23     container->get_variable(name)->instr_event(now, delta, resource, value);
24   }
25
26   // trace categorized resource utilization
27   if (TRACE_categorized() && not category.empty()) {
28     std::string category_type = name[0] + category;
29     XBT_DEBUG("CAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, category_type.c_str(), value);
30     container->get_variable(name)->instr_event(now, delta, resource, value);
31   }
32 }