19 #ifndef RIPPLE_TEST_CSF_COLLECTORS_H_INCLUDED
20 #define RIPPLE_TEST_CSF_COLLECTORS_H_INCLUDED
22 #include <ripple/basics/UnorderedContainers.h>
23 #include <test/csf/Histogram.h>
24 #include <test/csf/SimTime.h>
25 #include <test/csf/events.h>
52 template <
class... Cs>
57 template <
class C,
class E>
73 (...,
apply(std::get<Is>(
cs), who, when, e));
94 template <
class... Cs>
109 template <
class CollectorType>
129 byNode[who].on(who, when, e);
220 auto it =
txs.find(tx.id());
221 if (it !=
txs.end() && !it->second.accepted)
237 auto it =
txs.find(tx.id());
238 if (it !=
txs.end() && !it->second.validated)
256 return !it.second.accepted;
265 return !it.second.validated;
275 return double(count) / duration_cast<seconds>(simDuration).count();
279 return duration_cast<duration<float>>(dur).count();
347 template <
class T,
class Tag>
352 bool printHeaders =
false)
356 return double(count) / duration_cast<seconds>(simDuration).count();
360 return duration_cast<duration<float>>(dur).count();
383 <<
"txLatencySubmitToAccept10Pctl"
385 <<
"txLatencySubmitToAccept50Pctl"
387 <<
"txLatencySubmitToAccept90Pctl"
389 <<
"txLatencySubmitToValidatet10Pctl"
391 <<
"txLatencySubmitToValidatet50Pctl"
393 <<
"txLatencySubmitToValidatet90Pctl" <<
std::endl;
489 if (it != ledgers_.
end())
491 acceptToAccept.
insert(when - it->second.accepted);
504 assert(it != ledgers_.
end());
505 auto& tracker = it->second;
507 if (!tracker.fullyValidated)
510 tracker.fullyValidated = when;
511 acceptToFullyValid.
insert(when - tracker.accepted);
514 if (parentIt != ledgers_.
end())
516 auto& parentTracker = parentIt->second;
517 if (parentTracker.fullyValidated)
519 fullyValidToFullyValid.
insert(
520 when - *parentTracker.fullyValidated);
531 ledgers_.
begin(), ledgers_.
end(), [](
auto const& it) {
532 return !it.second.fullyValidated;
542 return double(count) / duration_cast<seconds>(simDuration).count();
546 return duration_cast<duration<float>>(dur).count();
600 template <
class T,
class Tag>
605 bool printHeaders =
false)
609 return double(count) / duration_cast<seconds>(simDuration).count();
613 return duration_cast<duration<float>>(dur).count();
620 <<
"ledgerNumAccepted"
622 <<
"ledgerNumFullyValidated"
624 <<
"ledgerRateAccepted"
626 <<
"ledgerRateFullyValidated"
628 <<
"ledgerLatencyAcceptToAccept10Pctl"
630 <<
"ledgerLatencyAcceptToAccept50Pctl"
632 <<
"ledgerLatencyAcceptToAccept90Pctl"
634 <<
"ledgerLatencyFullyValidToFullyValid10Pctl"
636 <<
"ledgerLatencyFullyValidToFullyValid50Pctl"
638 <<
"ledgerLatencyFullyValidToFullyValid90Pctl" <<
std::endl;
666 << fmtS(fullyValidToFullyValid.
percentile(0.1f))
670 << fmtS(fullyValidToFullyValid.
percentile(0.5f))
697 out << when.time_since_epoch().count() <<
": Node " << who
705 out << when.time_since_epoch().count() <<
": Node " << who
706 <<
" fully-validated "
void csv(SimDuration simDuration, T &log, Tag const &tag, bool printHeaders=false)
typename SimClock::time_point SimTime
T setprecision(T... args)
void on(PeerID, SimTime, E const &e)
Collector which ignores all events.
Saves information about Jumps for closed and fully validated ledgers.
CollectorType & operator[](PeerID who)
std::vector< Jump > fullyValidatedJumps
void on(PeerID, SimTime when, E const &e)
std::size_t unvalidated() const
T percentile(float p) const
Calculate the given percentile of the distribution.
void on(PeerID who, SimTime when, AcceptLedger const &e)
Peer fully validated a new ledger.
TxSetType const & txs() const
Ledger prior
The prior fully validated ledger This is a jump if prior.id() != ledger.parentID()
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void csv(SimDuration simDuration, T &log, Tag const &tag, bool printHeaders=false)
A ledger is a set of observed transactions and a sequence number identifying the ledger.
static void apply(C &c, PeerID who, SimTime when, E e)
Tracks the accepted -> validated evolution of ledgers.
void on(PeerID who, SimTime when, SubmitTx const &e)
void on(PeerID, SimTime, E const &e)
void on(PeerID who, SimTime when, AcceptLedger const &e)
void report(SimDuration simDuration, T &log, bool printBreakline=false)
Ledger ledger
The new fully validated ledger.
std::size_t orphaned() const
Tracks the overall duration of a simulation.
Peer accepted consensus results.
hash_map< Tx::ID, Tracker > txs
Tracks the submission -> accepted -> validated evolution of transactions.
void insert(T const &s)
Insert an sample.
static void apply(std::tuple< Cs &... > &cs, PeerID who, SimTime when, E e, std::index_sequence< Is... >)
std::size_t unvalidated() const
void on(PeerID who, SimTime when, E const &e)
hash_map< Ledger::ID, Tracker > ledgers_
void on(PeerID, SimTime, E const &e)
std::map< PeerID, CollectorType > byNode
Collectors< Cs... > makeCollectors(Cs &... cs)
Create an instance of Collectors<Cs...>
void on(PeerID, SimTime when, E const &e)
std::optional< SimTime > accepted
void on(PeerID who, SimTime when, AcceptLedger const &e)
void on(PeerID who, SimTime when, AcceptLedger const &e)
Tx tx
The submitted transaction.
CollectorType const & operator[](PeerID who) const
std::vector< Jump > closeJumps
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
Tracker(Tx tx_, SimTime submitted_)
T emplace_back(T... args)
void on(PeerID, SimTime, E const &e)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Hist fullyValidToFullyValid
std::optional< SimTime > fullyValidated
std::optional< SimTime > validated
void on(PeerID who, SimTime when, E e)
Tracker(SimTime accepted_)
void report(SimDuration simDuration, T &log, bool printBreakline=false)
typename SimClock::duration SimDuration
Maintain an instance of a Collector per peer.
Collectors(Cs &... cs_)
Constructor.
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
A transaction submitted to a peer.
Write out stream of ledger activity.