24 template <
typename event_rate_histogram_t>
26 std::chrono::nanoseconds ts,
char const* period_name,
27 event_rate_histogram_t
const& histo) {
29 <<
", min=" << histo.observed_min()
30 <<
", p25=" << histo.estimated_quantile(0.25)
31 <<
", p50=" << histo.estimated_quantile(0.50)
32 <<
", p75=" << histo.estimated_quantile(0.75)
33 <<
", p90=" << histo.estimated_quantile(0.90)
34 <<
", p99=" << histo.estimated_quantile(0.99)
35 <<
", p99.9=" << histo.estimated_quantile(0.999)
36 <<
", p99.99=" << histo.estimated_quantile(0.9999)
37 <<
", max=" << histo.observed_max()
38 <<
", N=" << histo.nsamples();
50 template <
typename event_rate_histogram_t>
51 void csv_rate(std::ostream& os, event_rate_histogram_t
const& histo) {
52 os <<
"," << histo.observed_min() <<
"," << histo.estimated_quantile(0.25)
53 <<
"," << histo.estimated_quantile(0.50) <<
"," 54 << histo.estimated_quantile(0.75) <<
"," << histo.estimated_quantile(0.90)
55 <<
"," << histo.estimated_quantile(0.99) <<
"," 56 << histo.estimated_quantile(0.999) <<
"," 57 << histo.estimated_quantile(0.9999) <<
"," << histo.observed_max();
73 template <
typename latency_histogram_t>
75 std::chrono::nanoseconds ts,
char const* name,
76 latency_histogram_t
const& histo) {
78 <<
", min=" << histo.observed_min()
79 <<
"ns, p0.01=" << histo.estimated_quantile(0.0001)
80 <<
"ns, p0.1=" << histo.estimated_quantile(0.001)
81 <<
"ns, p01=" << histo.estimated_quantile(0.01)
82 <<
"ns, p05=" << histo.estimated_quantile(0.05)
83 <<
"ns, p10=" << histo.estimated_quantile(0.10)
84 <<
"ns, p25=" << histo.estimated_quantile(0.25)
85 <<
"ns, p50=" << histo.estimated_quantile(0.50)
86 <<
"ns, p75=" << histo.estimated_quantile(0.75)
87 <<
"ns, p90=" << histo.estimated_quantile(0.90)
88 <<
"ns, p99=" << histo.estimated_quantile(0.99)
89 <<
"ns, max=" << histo.observed_max()
90 <<
"ns, N=" << histo.nsamples();
102 template <
typename latency_histogram_t>
103 void csv_arrival(std::ostream& os, latency_histogram_t
const& histo) {
104 os <<
"," << histo.observed_min() <<
"," << histo.estimated_quantile(0.0001)
105 <<
"," << histo.estimated_quantile(0.001) <<
"," 106 << histo.estimated_quantile(0.01) <<
"," << histo.estimated_quantile(0.05)
107 <<
"," << histo.estimated_quantile(0.10) <<
"," 108 << histo.estimated_quantile(0.25) <<
"," << histo.estimated_quantile(0.50)
109 <<
"," << histo.estimated_quantile(0.75) <<
"," 110 << histo.estimated_quantile(0.90) <<
"," << histo.estimated_quantile(0.99)
111 <<
"," << histo.observed_max();
127 template <
typename latency_histogram_t>
129 std::chrono::nanoseconds ts,
char const* name,
130 latency_histogram_t
const& histo) {
132 <<
", min=" << histo.observed_min()
133 <<
"ns, p10=" << histo.estimated_quantile(0.10)
134 <<
"ns, p25=" << histo.estimated_quantile(0.25)
135 <<
"ns, p50=" << histo.estimated_quantile(0.50)
136 <<
"ns, p75=" << histo.estimated_quantile(0.75)
137 <<
"ns, p90=" << histo.estimated_quantile(0.90)
138 <<
"ns, p99=" << histo.estimated_quantile(0.99)
139 <<
"ns, p99.9=" << histo.estimated_quantile(0.999)
140 <<
"ns, p99.99=" << histo.estimated_quantile(0.9999)
141 <<
"ns, max=" << histo.observed_max()
142 <<
"ns, N=" << histo.nsamples();
154 template <
typename latency_histogram_t>
155 void csv_latency(std::ostream& os, latency_histogram_t
const& histo) {
156 os <<
"," << histo.observed_min() <<
"," << histo.estimated_quantile(0.10)
157 <<
"," << histo.estimated_quantile(0.25) <<
"," 158 << histo.estimated_quantile(0.50) <<
"," << histo.estimated_quantile(0.75)
159 <<
"," << histo.estimated_quantile(0.90) <<
"," 160 << histo.estimated_quantile(0.99) <<
"," << histo.estimated_quantile(0.999)
161 <<
"," << histo.estimated_quantile(0.9999) <<
"," << histo.observed_max();
169 std::chrono::milliseconds(1))
172 std::chrono::microseconds(1))
175 std::chrono::nanoseconds(1))
180 , reporting_interval_(
183 , last_report_ts_(0) {
187 char const* fields[] = {
"min",
"p25",
"p50",
"p75",
"p90",
188 "p99",
"p999",
"p9999",
"max"};
189 char const* tracked[] = {
"RatePerSec",
"RatePerMSec",
"RatePerUSec"};
190 os <<
"Name,NSamples";
191 for (
auto t : tracked) {
192 for (
auto f : fields) {
196 os <<
",minArrival,p0001Arrival,p001Arrival,p01Arrival" 197 <<
",p05Arrival,p10Arrival,p25Arrival,p50Arrival,p75Arrival" 198 <<
",p90Arrival,p99Arrival,maxArrival";
199 os <<
",minProcessing,p10Processing,p25Processing,p50Processing" 200 <<
",p75Processing,p90Processing,p99Processing,p999Processing" 201 <<
",p9999Processing,maxProcessing";
206 using namespace std::chrono;
207 log_progress(duration_cast<nanoseconds>(std::chrono::hours(24)));
211 std::chrono::nanoseconds ts)
const {
225 std::chrono::nanoseconds ts, std::chrono::nanoseconds pl) {
236 std::chrono::nanoseconds d = ts -
last_ts_;
255 std::string
const& name, std::ostream& os)
const {
263 os <<
",,,,,,,,,,,,";
264 os <<
",,,,,,,,,,";
280 #ifndef JB_OFS_DEFAULTS_max_messages_per_second 281 #define JB_OFS_DEFAULTS_max_messages_per_second 1000000 283 #ifndef JB_OFS_DEFAULTS_max_messages_per_millisecond 284 #define JB_OFS_DEFAULTS_max_messages_per_millisecond 100000 286 #ifndef JB_OFS_DEFAULTS_max_messages_per_microsecond 287 #define JB_OFS_DEFAULTS_max_messages_per_microsecond 100000 289 #ifndef JB_OFS_DEFAULTS_max_interarrival_time_nanoseconds 290 #define JB_OFS_DEFAULTS_max_interarrival_time_nanoseconds 100000 292 #ifndef JB_OFS_DEFAULTS_max_processing_latency_nanoseconds 293 #define JB_OFS_DEFAULTS_max_processing_latency_nanoseconds 1000000 295 #ifndef JB_OFS_DEFAULTS_reporting_interval_seconds 296 #define JB_OFS_DEFAULTS_reporting_interval_seconds 600 313 desc(
"max-messages-per-second")
315 "Configure the per-second messages rate histogram to expect" 316 " no more than this number of messages per second." 317 " Higher values consume more memory, but give more accurate" 318 " results for high percentiles."),
321 desc(
"max-messages-per-millisecond")
323 "Configure the per-millisecond messages rate histogram to " 325 " no more than this number of messages per millisecond." 326 " Higher values consume more memory, but give more accurate" 327 " results for high percentiles."),
330 desc(
"max-messages-per-microsecond")
332 "Configure the per-microsecond messages rate histogram to " 334 " no more than this number of messages per microsecond." 335 " Higher values consume more memory, but give more accurate" 336 " results for high percentiles."),
339 desc(
"max-interarrival-time-nanoseconds")
341 "Configure the interarrival time histogram to expect" 342 " no more than this time between messages." 343 " Higher values consume more memory, but give more accurate" 344 " results for high percentiles."),
347 desc(
"max-processing-time-nanoseconds")
349 "Configure the processing latency histogram to expect" 350 " no more that no processing time is higher than this value." 351 " Higher values consume more memory, but give more accurate" 352 " results for high percentiles."),
355 desc(
"reporting-interval-seconds")
356 .help(
"Configure how often the statistics are logged." 357 " Use 0 to suppress all logging." 358 " The time is measured using the even timestamps," 359 " for feeds using recorded or simulated timestamps the" 360 " reporting interval will not match the wall time."),
366 std::ostringstream os;
367 os <<
"max-messages-per-second must be > 1, value=" 373 std::ostringstream os;
374 os <<
"max-messages-per-millisecond must be > 1, value=" 380 std::ostringstream os;
381 os <<
"max-messages-per-microsecond must be > 1, value=" 387 std::ostringstream os;
388 os <<
"max-interarrival-time-nanoseconds must be > 1, value=" 394 std::ostringstream os;
395 os <<
"max-processing_latency-nanoseconds must be > 1, value=" 401 std::ostringstream os;
402 os <<
"reporting-interval-seconds must be > 1, value=" jb::config_attribute< config, int > reporting_interval_seconds
rate_histogram per_sec_rate_
void record_sample(std::chrono::nanoseconds ts, std::chrono::nanoseconds processing_latency)
Refactor non-template portions of sample()
void sample(sample_type const &t)
Record a new sample.
Define defaults for program parameters.
#define JB_OFS_DEFAULTS_max_processing_latency_nanoseconds
void log_progress(std::chrono::nanoseconds ts) const
Report progress up to a certain point in the input.
std::int64_t max_interarrival_time_nanoseconds
#define JB_OFS_DEFAULTS_max_messages_per_second
#define JB_OFS_DEFAULTS_max_messages_per_millisecond
int reporting_interval_seconds
int max_messages_per_millisecond
Helper class to print time durations s in HHMMSS format.
std::chrono::nanoseconds last_report_ts_
void sample(duration_type ts)
Record a new sample.
jb::config_attribute< config, int > max_messages_per_microsecond
jb::config_attribute< config, int > max_processing_latency_nanoseconds
int max_messages_per_microsecond
#define JB_OFS_DEFAULTS_reporting_interval_seconds
jb::config_attribute< config, std::int64_t > max_interarrival_time_nanoseconds
offline_feed_statistics(config const &cfg)
Constructor.
#define JB_OFS_DEFAULTS_max_messages_per_microsecond
jb::config_attribute< config, int > max_messages_per_millisecond
jb::config_attribute< config, int > max_messages_per_second
void print_csv(std::string const &name, std::ostream &os) const
Print all the measurements in CSV format.
rate_histogram per_msec_rate_
std::chrono::nanoseconds last_ts_
rate_histogram per_usec_rate_
A simple class to communicate the result of parsing the options.
#define JB_OFS_DEFAULTS_max_interarrival_time_nanoseconds
void log_final_progress() const
Final progress report at the end of the input.
interarrival_histogram_t interarrival_
std::chrono::seconds reporting_interval_
processing_latency_histogram_t processing_latency_
static void print_csv_header(std::ostream &os)
Print a CSV header.
int max_processing_latency_nanoseconds
std::uint64_t nsamples() const
Return the number of samples observed to this point.
Configure an offline_feed_statistics object.
int max_messages_per_second
The top-level namespace for the JayBeams library.
void validate() const override
Validate the configuration.