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)
232 return std::count_if(
txs.begin(),
txs.end(), [](
auto const& it) { return !it.second.accepted; });
239 return std::count_if(
txs.begin(),
txs.end(), [](
auto const& it) { return !it.second.validated; });
248 return double(count) / duration_cast<seconds>(simDuration).count();
251 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
299 template <
class T,
class Tag>
305 return double(count) / duration_cast<seconds>(simDuration).count();
308 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
312 log <<
"tag" <<
"," <<
"txNumSubmitted" <<
"," <<
"txNumAccepted"
313 <<
"," <<
"txNumValidated" <<
"," <<
"txNumOrphaned" <<
","
314 <<
"txUnvalidated" <<
"," <<
"txRateSumbitted" <<
","
315 <<
"txRateAccepted" <<
"," <<
"txRateValidated" <<
","
316 <<
"txLatencySubmitToAccept10Pctl" <<
","
317 <<
"txLatencySubmitToAccept50Pctl" <<
","
318 <<
"txLatencySubmitToAccept90Pctl" <<
","
319 <<
"txLatencySubmitToValidatet10Pctl" <<
","
320 <<
"txLatencySubmitToValidatet50Pctl" <<
","
321 <<
"txLatencySubmitToValidatet90Pctl" <<
std::endl;
432 auto& tracker = it->second;
434 if (!tracker.fullyValidated)
437 tracker.fullyValidated = when;
443 auto& parentTracker = parentIt->second;
444 if (parentTracker.fullyValidated)
457 ledgers_.begin(),
ledgers_.end(), [](
auto const& it) { return !it.second.fullyValidated; });
466 return double(count) / duration_cast<seconds>(simDuration).count();
469 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
509 template <
class T,
class Tag>
515 return double(count) / duration_cast<seconds>(simDuration).count();
518 auto fmtS = [](
SimDuration dur) {
return duration_cast<duration<float>>(dur).count(); };
522 log <<
"tag" <<
"," <<
"ledgerNumAccepted" <<
","
523 <<
"ledgerNumFullyValidated" <<
"," <<
"ledgerRateAccepted"
524 <<
"," <<
"ledgerRateFullyValidated" <<
","
525 <<
"ledgerLatencyAcceptToAccept10Pctl" <<
","
526 <<
"ledgerLatencyAcceptToAccept50Pctl" <<
","
527 <<
"ledgerLatencyAcceptToAccept90Pctl" <<
","
528 <<
"ledgerLatencyFullyValidToFullyValid10Pctl" <<
","
529 <<
"ledgerLatencyFullyValidToFullyValid50Pctl" <<
","
530 <<
"ledgerLatencyFullyValidToFullyValid90Pctl" <<
std::endl;
586 out << when.time_since_epoch().count() <<
": Node " << who <<
" accepted " <<
"L" << e.
ledger.
id() <<
" "
593 out << when.time_since_epoch().count() <<
": Node " << who <<
" fully-validated " <<
"L" << e.
ledger.
id() <<
" "
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)