1 /* Copyright (c) 2010-2023. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "src/instr/instr_private.hpp"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorized resource utilization");
13 namespace simgrid::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)
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)
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);
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);
35 } // namespace simgrid::instr