1#ifndef XRPL_TEST_CSF_COLLECTORS_H_INCLUDED
2#define XRPL_TEST_CSF_COLLECTORS_H_INCLUDED
4#include <test/csf/Histogram.h>
5#include <test/csf/SimTime.h>
6#include <test/csf/events.h>
8#include <xrpl/basics/UnorderedContainers.h>
40 template <
class C,
class E>
92template <
class CollectorType>
112 byNode[who].on(who, when, e);
203 auto it =
txs.find(tx.id());
204 if (it !=
txs.end() && !it->second.accepted)
220 auto it =
txs.find(tx.id());
221 if (it !=
txs.end() && !it->second.validated)
239 return !it.second.accepted;
248 return !it.second.validated;
258 return double(count) / duration_cast<seconds>(simDuration).count();
262 return duration_cast<duration<float>>(dur).count();
275 <<
"Count" <<
"|" <<
std::setw(7) <<
"Per Sec" <<
"|"
326 template <
class T,
class Tag>
331 bool printHeaders =
false)
335 return double(count) / duration_cast<seconds>(simDuration).count();
339 return duration_cast<duration<float>>(dur).count();
344 log <<
"tag" <<
"," <<
"txNumSubmitted" <<
"," <<
"txNumAccepted"
345 <<
"," <<
"txNumValidated" <<
"," <<
"txNumOrphaned" <<
","
346 <<
"txUnvalidated" <<
"," <<
"txRateSumbitted" <<
","
347 <<
"txRateAccepted" <<
"," <<
"txRateValidated" <<
","
348 <<
"txLatencySubmitToAccept10Pctl" <<
","
349 <<
"txLatencySubmitToAccept50Pctl" <<
","
350 <<
"txLatencySubmitToAccept90Pctl" <<
","
351 <<
"txLatencySubmitToValidatet10Pctl" <<
","
352 <<
"txLatencySubmitToValidatet50Pctl" <<
","
353 <<
"txLatencySubmitToValidatet90Pctl" <<
std::endl;
465 auto& tracker = it->second;
467 if (!tracker.fullyValidated)
470 tracker.fullyValidated = when;
476 auto& parentTracker = parentIt->second;
477 if (parentTracker.fullyValidated)
480 when - *parentTracker.fullyValidated);
492 return !it.second.fullyValidated;
502 return double(count) / duration_cast<seconds>(simDuration).count();
506 return duration_cast<duration<float>>(dur).count();
558 template <
class T,
class Tag>
563 bool printHeaders =
false)
567 return double(count) / duration_cast<seconds>(simDuration).count();
571 return duration_cast<duration<float>>(dur).count();
576 log <<
"tag" <<
"," <<
"ledgerNumAccepted" <<
","
577 <<
"ledgerNumFullyValidated" <<
"," <<
"ledgerRateAccepted"
578 <<
"," <<
"ledgerRateFullyValidated" <<
","
579 <<
"ledgerLatencyAcceptToAccept10Pctl" <<
","
580 <<
"ledgerLatencyAcceptToAccept50Pctl" <<
","
581 <<
"ledgerLatencyAcceptToAccept90Pctl" <<
","
582 <<
"ledgerLatencyFullyValidToFullyValid10Pctl" <<
","
583 <<
"ledgerLatencyFullyValidToFullyValid50Pctl" <<
","
584 <<
"ledgerLatencyFullyValidToFullyValid90Pctl" <<
std::endl;
643 out << when.time_since_epoch().count() <<
": Node " << who
651 out << when.time_since_epoch().count() <<
": Node " << who
652 <<
" fully-validated " <<
"L" << e.
ledger.
id() <<
" "
static void apply(std::tuple< Cs &... > &cs, PeerID who, SimTime when, E e, std::index_sequence< Is... >)
static void apply(C &c, PeerID who, SimTime when, E e)
void on(PeerID who, SimTime when, E e)
Collectors(Cs &... cs_)
Constructor.
void insert(T const &s)
Insert an sample.
T percentile(float p) const
Calculate the given percentile of the distribution.
A ledger is a set of observed transactions and a sequence number identifying the ledger.
TxSetType const & txs() const
typename SimClock::duration SimDuration
typename SimClock::time_point SimTime
Collectors< Cs... > makeCollectors(Cs &... cs)
Create an instance of Collectors<Cs...>
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T setprecision(T... args)
Peer accepted consensus results.
Maintain an instance of a Collector per peer.
CollectorType const & operator[](PeerID who) const
void on(PeerID who, SimTime when, E const &e)
std::map< PeerID, CollectorType > byNode
CollectorType & operator[](PeerID who)
Peer fully validated a new ledger.
Ledger prior
The prior fully validated ledger This is a jump if prior.id() != ledger.parentID()
Ledger ledger
The new fully validated ledger.
Saves information about Jumps for closed and fully validated ledgers.
std::vector< Jump > fullyValidatedJumps
void on(PeerID who, SimTime when, AcceptLedger const &e)
void on(PeerID, SimTime, E const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
std::vector< Jump > closeJumps
Tracker(SimTime accepted_)
std::optional< SimTime > fullyValidated
Tracks the accepted -> validated evolution of ledgers.
void on(PeerID, SimTime, E const &e)
void on(PeerID who, SimTime when, AcceptLedger const &e)
std::size_t unvalidated() const
hash_map< Ledger::ID, Tracker > ledgers_
void report(SimDuration simDuration, T &log, bool printBreakline=false)
Hist fullyValidToFullyValid
void csv(SimDuration simDuration, T &log, Tag const &tag, bool printHeaders=false)
std::size_t fullyValidated
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
Collector which ignores all events.
void on(PeerID, SimTime, E const &e)
Tracks the overall duration of a simulation.
void on(PeerID, SimTime when, E const &e)
Write out stream of ledger activity.
void on(PeerID who, SimTime when, AcceptLedger const &e)
void on(PeerID, SimTime, E const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
A transaction submitted to a peer.
Tx tx
The submitted transaction.
std::optional< SimTime > accepted
std::optional< SimTime > validated
Tracker(Tx tx_, SimTime submitted_)
Tracks the submission -> accepted -> validated evolution of transactions.
std::size_t orphaned() const
hash_map< Tx::ID, Tracker > txs
void on(PeerID who, SimTime when, SubmitTx const &e)
void csv(SimDuration simDuration, T &log, Tag const &tag, bool printHeaders=false)
std::size_t unvalidated() const
void report(SimDuration simDuration, T &log, bool printBreakline=false)
void on(PeerID, SimTime when, E const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void on(PeerID who, SimTime when, AcceptLedger const &e)