#include "xbt/sysdep.h"
#include <algorithm>
-//#include <function>
#include <boost/tokenizer.hpp>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ker_resource);
void FactorSet::parse(const std::string& values)
{
- const char* str = values.c_str();
initialized_ = true;
- if (strchr(str, ':') == nullptr && strchr(str, ';') == nullptr) { // Single value
- default_value_ = xbt_str_parse_double(str, name_.c_str());
+ if (values.find_first_of(":;") == std::string::npos) { // Single value
+ default_value_ = xbt_str_parse_double(values.c_str(), name_.c_str());
return;
}
auto const& fact = factors_[i];
if (size <= fact.factor) { // Too large already, use the previous value
-
if (i == 0) { // Before the first boundary: use the default value
XBT_DEBUG("%s: %f <= %zu return default %f", name_.c_str(), size, fact.factor, default_value_);
return default_value_;
return cfg_latency_factor(0);
}
-#if 0
double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& links,
const std::unordered_set<s4u::NetZone*>& netzones)
return cfg_latency_factor(size);
}
-double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& links,
- const std::unordered_set<s4u::NetZone*>& netzones)
-{
- if (bw_factor_cb_)
- return bw_factor_cb_(size, src, dst, links, netzones);
-
- if (not cfg_bandwidth_factor.is_initialized())
- cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
-
- return cfg_bandwidth_factor(size);
-}
-#endif
-
-double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& links,
- const std::unordered_set<s4u::NetZone*>& netzones)
-{
- if (lat_factor_cb_)
- return lat_factor_cb_(size, src, dst, links, netzones);
-
- if (not cfg_latency_factor.is_initialized()) // lazy initiaization to avoid initialization fiasco
- cfg_latency_factor.parse(cfg_latency_factor_str.get());
-
- return cfg_latency_factor(size);
-}
double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& links,
const std::unordered_set<s4u::NetZone*>& netzones)