Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / instr / instr_resource_utilization.cpp
1 /* Copyright (c) 2010-2022. 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 namespace simgrid {
13 namespace instr {
14 void resource_set_utilization(const char* type, const char* name, const char* resource, const std::string& category,
15                               double value, double now, double delta)
16 {
17   // only trace resource utilization if resource is known by tracing mechanism
18   Container* container = Container::by_name_or_null(resource);
19   if (container == nullptr || value == 0.0)
20     return;
21
22   // trace uncategorized resource utilization
23   if (TRACE_uncategorized()){
24     XBT_VERB("UNCAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, name, value);
25     container->get_variable(name)->instr_event(now, delta, resource, value);
26   }
27
28   // trace categorized resource utilization
29   if (TRACE_categorized() && not category.empty()) {
30     std::string category_type = name[0] + category;
31     XBT_DEBUG("CAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, category_type.c_str(), value);
32     container->get_variable(name)->instr_event(now, delta, resource, value);
33   }
34 }
35 } // namespace instr
36 } // namespace simgrid