/* Add the first fake event storing the time at which the trace begins */
DatedValue val(0, -1);
StochasticDatedValue stoval(0, -1);
- event_list.push_back(val);
- stochastic_event_list.push_back(stoval);
+ event_list.emplace_back(val);
+ stochastic_event_list.emplace_back(stoval);
}
Profile::~Profile() = default;
fes_ = fes;
fes_->add_event(0.0 /* start time */, event);
- if (stochastic > 0) {
- xbt_assert((event->idx < stochastic_event_list.size()), "Your profile should have at least one stochastic event!");
+ if (stochastic) {
+ xbt_assert(event->idx < stochastic_event_list.size(), "Your profile should have at least one stochastic event!");
futureDV = stochastic_event_list.at(event->idx).get_datedvalue();
}
DatedValue dateVal = futureDV;
if (event->idx < stochastic_event_list.size() - 1) {
event->idx++;
- } else if (stochasticloop > 0) { /* We have reached the last element and we have to loop. */
+ } else if (stochasticloop) { /* We have reached the last element and we have to loop. */
event->idx = 1;
} else {
event->free_me = true; /* We have reached the last element, but we don't need to loop. */
}
- if (event->free_me == false) { // In the case there is an element, we draw the next event
- StochasticDatedValue stodateVal = stochastic_event_list.at(event->idx);
- futureDV = stochastic_event_list.at(event->idx).get_datedvalue();
+ if (not event->free_me) { // In the case there is an element, we draw the next event
+ futureDV = stochastic_event_list.at(event->idx).get_datedvalue();
fes_->add_event(event_date + futureDV.date_, event);
}
return dateVal;
stochevent.value_params = {std::atof(splittedval[i + 1].c_str()), std::atof(splittedval[i + 2].c_str())};
}
- profile->stochastic_event_list.push_back(stochevent);
+ profile->stochastic_event_list.emplace_back(stochevent);
} else {
XBT_ATTRIB_UNUSED int res = sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_);
xbt_assert(res == 2, "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str());
last_event->date_, event.date_, input.c_str());
last_event->date_ = event.date_ - last_event->date_;
- profile->event_list.push_back(event);
+ profile->event_list.emplace_back(event);
last_event = &(profile->event_list.back());
}
}
"DET 0 UNIF 10 20");
std::vector<simgrid::kernel::profile::StochasticDatedValue> want;
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(0, -1)); // The initial fake event
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {0},
- simgrid::kernel::profile::Dist_Unif, {10, 20}));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(0, -1)); // The initial fake event
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {0},
+ simgrid::kernel::profile::Dist_Unif, {10, 20}));
REQUIRE(want == got);
}
"DET 5 UNIF 5 25");
std::vector<simgrid::kernel::profile::StochasticDatedValue> want;
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(0, -1));
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {0},
- simgrid::kernel::profile::Dist_Det, {4}));
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Norm, {25, 10},
- simgrid::kernel::profile::Dist_Det, {3}));
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Unif, {10, 20},
- simgrid::kernel::profile::Dist_Norm, {25, 10}));
- want.push_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {5},
- simgrid::kernel::profile::Dist_Unif, {5, 25}));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(0, -1));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {0},
+ simgrid::kernel::profile::Dist_Det, {4}));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Norm, {25, 10},
+ simgrid::kernel::profile::Dist_Det, {3}));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Unif, {10, 20},
+ simgrid::kernel::profile::Dist_Norm, {25, 10}));
+ want.emplace_back(simgrid::kernel::profile::StochasticDatedValue(simgrid::kernel::profile::Dist_Det, {5},
+ simgrid::kernel::profile::Dist_Unif, {5, 25}));
REQUIRE(want == got);
}
std::vector<simgrid::kernel::profile::DatedValue> want;
// The following values were drawn using the XBT_RNG_xbt method /outside/ the testcase.
- want.push_back(simgrid::kernel::profile::DatedValue(0, 19.29616086867082813683));
- want.push_back(simgrid::kernel::profile::DatedValue(2.32719992449416279712, 20.16807234800742065772));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(0, 19.29616086867082813683));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(2.32719992449416279712, 20.16807234800742065772));
REQUIRE(want == got);
}
// In this case, the main use of the last stochastic event is to set when the first event takes place.
std::vector<simgrid::kernel::profile::DatedValue> want;
- want.push_back(simgrid::kernel::profile::DatedValue(0, 19.29616086867082813683));
- want.push_back(simgrid::kernel::profile::DatedValue(2.32719992449416279712, 20.16807234800742065772));
- want.push_back(simgrid::kernel::profile::DatedValue(3.51111873684917075167, 0));
- want.push_back(simgrid::kernel::profile::DatedValue(3.51111873684917075167, 10.39759496468994726115));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(0, 19.29616086867082813683));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(2.32719992449416279712, 20.16807234800742065772));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(3.51111873684917075167, 0));
+ want.emplace_back(simgrid::kernel::profile::DatedValue(3.51111873684917075167, 10.39759496468994726115));
REQUIRE(want == got);
}