JayBeams  0.1
Another project to have fun coding.
book_depth_statistics.hpp
Go to the documentation of this file.
1 #ifndef jb_book_depth_stats_hpp
2 #define jb_book_depth_stats_hpp
3 
4 #include <jb/config_object.hpp>
6 #include <jb/histogram.hpp>
8 
9 #include <iosfwd>
10 
11 namespace jb {
12 typedef unsigned long int book_depth_t;
13 
14 /**
15  * Keep statistics about a feed and its book depth.
16  */
18 public:
19  class config;
20 
21  /// Constructor
22  explicit book_depth_statistics(config const& cfg);
23 
24  /**
25  * Record a sample, that is book depth value after the event.
26  *
27  * @tparam book_depth_t the type used to record
28  * the book depth after processing the event.
29  * @param book_depth : the book depth (after processing the event)
30  * to be recorded.
31  */
32  template <typename book_depth_t>
33  void sample(book_depth_t book_depth) {
34  book_depth_.sample(book_depth);
35  }
36 
37  /**
38  * Print a CSV header.
39  *
40  * The fields include:
41  * - name: the name of the book_depth_statistics<> object.
42  * - nsamples: the number of samples received.
43  * - minBookDepth: the minimum book depth observed
44  * - p25BookDepth: the 25th percentile for book depth observed
45  * - p50BookDepth: the 50th percentile for book depth observed
46  * - p75BookDepth: the 75th percentile for book depth observed
47  * - p90BookDepth: the 90th percentile for book depth observed
48  * - p99BookDepth: the 99th percentile for book depth observed
49  * - p999BookDepth: the 99.9th percentile for book depth observed
50  * - p9999BookDepth: the 99.99th percentile for book depth observed
51  * - maxBookDepth: the maximum for book depth observed
52  *
53  * @param os the output stream
54  */
55  static void print_csv_header(std::ostream& os);
56 
57  /**
58  * Print all the measurements in CSV format.
59  */
60  void print_csv(std::string const& name, std::ostream& os) const;
61 
62 private:
64  book_depth_histogram_t book_depth_;
65 };
66 
67 /**
68  * Configure a book_depth_statistics object.
69  */
71 public:
72  config();
74 
75  /// Validate the configuration
76  void validate() const override;
77 
78  /// No more than this value is recorded
80 };
81 
82 } // namespace jb
83 
84 #endif // jb_book_depth_statistics_hpp
void sample(sample_type const &t)
Record a new sample.
Definition: histogram.hpp:197
Base class for all configuration objects.
void sample(book_depth_t book_depth)
Record a sample, that is book depth value after the event.
static void print_csv_header(std::ostream &os)
Print a CSV header.
A histogram class with controllable binning and range strategy.
Definition: histogram.hpp:46
histogram< integer_range_binning< book_depth_t > > book_depth_histogram_t
Keep statistics about a feed and its book depth.
void print_csv(std::string const &name, std::ostream &os) const
Print all the measurements in CSV format.
#define config_object_constructors(NAME)
book_depth_histogram_t book_depth_
Helper class to easily define configuration attributes.
jb::config_attribute< config, book_depth_t > max_book_depth
No more than this value is recorded.
Configure a book_depth_statistics object.
unsigned long int book_depth_t
book_depth_statistics(config const &cfg)
Constructor.
The top-level namespace for the JayBeams library.
Definition: as_hhmmss.hpp:7