3#include <xrpl/beast/utility/instrumentation.h>
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/IOUAmount.h>
6#include <xrpl/protocol/STAmount.h>
7#include <xrpl/protocol/UintTypes.h>
8#include <xrpl/protocol/XRPAmount.h>
9#include <xrpl/tx/paths/detail/EitherAmount.h>
11#include <boost/container/flat_map.hpp>
27 boost::container::flat_map<std::string, std::pair<time_point, time_point>>
timePoints;
28 boost::container::flat_map<std::string, std::size_t>
counts;
65 out.push_back(outAmt);
74 "xrpl::path::detail::FlowDebugInfo::pushLiquiditySrc : "
75 "non-empty liquidity source");
110 "xrpl::path::detail::FlowDebugInfo::duration : timepoint not "
115 auto const& t = i->second;
122 auto i =
counts.find(tag);
146 Stopper(Stopper&&) =
default;
148 return Stopper(std::move(name), *
this);
154 auto i =
counts.find(tag);
177 passInfo.pushBack(in, out, activeStrands);
199 ostr <<
"duration: " << d.count() <<
", pass_count: " <<
passCount();
203 auto writeList = [&ostr](
auto const& vals,
auto&& fun,
char delim =
';') {
207 ostr << fun(vals[0]);
208 for (
size_t i = 1, e = vals.size(); i < e; ++i)
209 ostr << delim << fun(vals[i]);
213 auto writeXrpAmtList = [&writeList](
218 writeList(amts, getVal, delim);
220 auto writeIouAmtList = [&writeList](
225 writeList(amts, getVal, delim);
229 auto getVal = [](
size_t const& v) ->
size_t const& {
return v; };
230 writeList(vals, getVal);
232 auto writeNestedIouAmtList =
237 writeIouAmtList(amts[0],
'|');
238 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
241 writeIouAmtList(amts[i],
'|');
246 auto writeNestedXrpAmtList =
251 writeXrpAmtList(amts[0],
'|');
252 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
255 writeXrpAmtList(amts[i],
'|');
261 ostr <<
", in_pass: ";
270 ostr <<
", out_pass: ";
279 ostr <<
", num_active: ";
281 if (!
passInfo.liquiditySrcIn.empty() && !
passInfo.liquiditySrcIn.back().empty())
283 ostr <<
", l_src_in: ";
286 writeNestedXrpAmtList(
passInfo.liquiditySrcIn);
290 writeNestedIouAmtList(
passInfo.liquiditySrcIn);
292 ostr <<
", l_src_out: ";
295 writeNestedXrpAmtList(
passInfo.liquiditySrcOut);
299 writeNestedIouAmtList(
passInfo.liquiditySrcOut);
314 auto const k = elem.first;
315 auto const v = elem.second;
316 ostr << '[' << get<0>(k) <<
'|' <<
get<1>(k) <<
'|' <<
get<2>(k) <<
'|' << v <<
']';
Floating point representation of amounts with high dynamic range.
T duration_cast(T... args)
void writeDiffs(std::ostringstream &ostr, Iter begin, Iter end)
void writeDiffElement(std::ostringstream &ostr, std::pair< std::tuple< AccountID, AccountID, Currency >, STAmount > const &elem)
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
std::string to_string(BaseUInt< Bits, Tag > const &a)
std::vector< std::vector< EitherAmount > > liquiditySrcOut
std::vector< EitherAmount > in
void pushBack(EitherAmount const &inAmt, EitherAmount const &outAmt, std::size_t active)
std::vector< size_t > numActive
void pushLiquiditySrc(EitherAmount const &eIn, EitherAmount const &eOut)
std::vector< EitherAmount > out
PassInfo(bool nativeIn, bool nativeOut)
std::vector< std::vector< EitherAmount > > liquiditySrcIn
void pushPass(EitherAmount const &in, EitherAmount const &out, std::size_t activeStrands)
void pushLiquiditySrc(EitherAmount const &in, EitherAmount const &out)
std::string toString(bool writePassInfo) const
std::size_t count(std::string const &tag) const
std::size_t passCount() const
FlowDebugInfo(bool nativeIn, bool nativeOut)
boost::container::flat_map< std::string, std::size_t > counts
clock::time_point time_point
void inc(std::string const &tag)
void setCount(std::string const &tag, std::size_t c)
auto duration(std::string const &tag) const
auto timeBlock(std::string name)
std::chrono::high_resolution_clock clock
boost::container::flat_map< std::string, std::pair< time_point, time_point > > timePoints