3#include <test/csf/Histogram.h>
4#include <test/csf/SimTime.h>
5#include <test/csf/events.h>
7#include <xrpl/basics/UnorderedContainers.h>
39 template <
class C,
class E>
86template <
class CollectorType>
106 byNode[who].on(who, when, e);
197 auto it =
txs.find(tx.id());
198 if (it !=
txs.end() && !it->second.accepted)
214 auto it =
txs.find(tx.id());
215 if (it !=
txs.end() && !it->second.validated)
233 txs.begin(),
txs.end(), [](
auto const& it) { return !it.second.accepted; });
241 txs.begin(),
txs.end(), [](
auto const& it) { return !it.second.validated; });
250 return double(count) / duration_cast<seconds>(simDuration).count();
253 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
303 template <
class T,
class Tag>
309 return double(count) / duration_cast<seconds>(simDuration).count();
312 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
316 log <<
"tag" <<
"," <<
"txNumSubmitted" <<
"," <<
"txNumAccepted"
317 <<
"," <<
"txNumValidated" <<
"," <<
"txNumOrphaned" <<
","
318 <<
"txUnvalidated" <<
"," <<
"txRateSumbitted" <<
","
319 <<
"txRateAccepted" <<
"," <<
"txRateValidated" <<
","
320 <<
"txLatencySubmitToAccept10Pctl" <<
","
321 <<
"txLatencySubmitToAccept50Pctl" <<
","
322 <<
"txLatencySubmitToAccept90Pctl" <<
","
323 <<
"txLatencySubmitToValidatet10Pctl" <<
","
324 <<
"txLatencySubmitToValidatet50Pctl" <<
","
325 <<
"txLatencySubmitToValidatet90Pctl" <<
std::endl;
436 auto& tracker = it->second;
438 if (!tracker.fullyValidated)
441 tracker.fullyValidated = when;
447 auto& parentTracker = parentIt->second;
448 if (parentTracker.fullyValidated)
461 return !it.second.fullyValidated;
471 return double(count) / duration_cast<seconds>(simDuration).count();
474 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
515 template <
class T,
class Tag>
521 return double(count) / duration_cast<seconds>(simDuration).count();
524 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
528 log <<
"tag" <<
"," <<
"ledgerNumAccepted" <<
","
529 <<
"ledgerNumFullyValidated" <<
"," <<
"ledgerRateAccepted"
530 <<
"," <<
"ledgerRateFullyValidated" <<
","
531 <<
"ledgerLatencyAcceptToAccept10Pctl" <<
","
532 <<
"ledgerLatencyAcceptToAccept50Pctl" <<
","
533 <<
"ledgerLatencyAcceptToAccept90Pctl" <<
","
534 <<
"ledgerLatencyFullyValidToFullyValid10Pctl" <<
","
535 <<
"ledgerLatencyFullyValidToFullyValid50Pctl" <<
","
536 <<
"ledgerLatencyFullyValidToFullyValid90Pctl" <<
std::endl;
592 out << when.time_since_epoch().count() <<
": Node " << who <<
" accepted " <<
"L"
599 out << when.time_since_epoch().count() <<
": Node " << who <<
" fully-validated " <<
"L"
static void apply(std::tuple< Cs &... > &cs, PeerID who, SimTime when, E e, std::index_sequence< Is... >)
void on(PeerID who, SimTime when, E e)
Collectors(Cs &... cs_)
Constructor.
static void apply(C &c, PeerID who, SimTime when, E e)
T percentile(float p) const
Calculate the given percentile of the distribution.
void insert(T const &s)
Insert an sample.
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, SimTime, E const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void on(PeerID who, SimTime when, AcceptLedger const &e)
std::vector< Jump > closeJumps
std::optional< SimTime > fullyValidated
Tracker(SimTime accepted_)
Tracks the accepted -> validated evolution of ledgers.
hash_map< Ledger::ID, Tracker > ledgers_
void on(PeerID who, SimTime when, AcceptLedger const &e)
void csv(SimDuration simDuration, T &log, Tag const &tag, bool printHeaders=false)
void on(PeerID, SimTime, E const &e)
std::size_t fullyValidated
Hist fullyValidToFullyValid
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void report(SimDuration simDuration, T &log, bool printBreakline=false)
std::size_t unvalidated() const
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, SimTime, E const &e)
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
void on(PeerID who, SimTime when, AcceptLedger 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.
void report(SimDuration simDuration, T &log, bool printBreakline=false)
void on(PeerID who, SimTime when, AcceptLedger const &e)
std::size_t orphaned() const
void on(PeerID who, SimTime when, FullyValidateLedger const &e)
std::size_t unvalidated() const
void on(PeerID, SimTime when, E const &e)
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)