srs-control 0.2.2
Loading...
Searching...
No Matches
AppReport.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstddef>
5#include <cstdint>
6#include <map>
7#include <string>
8#include <string_view>
9#include <utility>
10#include <vector>
11
12namespace srs
13{
15 {
16 public:
17 struct TaskStat
18 {
19 double total_time_ms{};
21 };
22
24 {
25 using US = std::chrono::microseconds;
26 using USCount = decltype(US{}.count());
30 std::string_view connection_name;
31 };
32
34 {
35 std::size_t n_frames{};
36 std::size_t total_time_ns{};
37 std::size_t total_bytes_read{};
38 };
39
40 struct QueueStat
41 {
42 std::size_t empty_trash{};
43 std::size_t full_trash{};
44 std::size_t full_valid{};
45 };
46
47 void register_switch_socket_result(std::string socket_name,
48 std::vector<std::pair<std::string, FecSwitchStat>> socket_times)
49 {
50 switch_socket_records_.emplace_back(std::string{ socket_name }, std::move(socket_times));
51 }
52
53 void register_frame_reading_result(std::string name, const FrameReadingStat& stat)
54 {
55 frame_reading_records_.emplace_back(std::string{ name }, stat);
56 }
57
58 void register_task_result(std::string_view task_name, const std::vector<TaskStat>& process_times)
59 {
60 task_records_.try_emplace(std::string{ task_name }, process_times);
61 }
62
63 void register_output_sink_result(std::string_view sink_name, const std::vector<std::size_t>& bytes_written)
64 {
65 sink_records_.try_emplace(std::string{ sink_name }, bytes_written);
66 }
67
68 void register_queue_result(const QueueStat& stat) { queue_record_.second = stat; }
69
70 ~AppReport();
71
72 private:
73 std::map<std::string, std::vector<TaskStat>> task_records_;
74 std::map<std::string, std::vector<std::size_t>> sink_records_;
75 std::vector<std::pair<std::string, std::vector<std::pair<std::string, FecSwitchStat>>>> switch_socket_records_;
76 std::vector<std::pair<std::string, FrameReadingStat>> frame_reading_records_;
77 std::pair<std::string_view, QueueStat> queue_record_{ std::string_view{ "Counts" }, {} };
78
79 void report_task_result();
83
85 };
86} // namespace srs
std::vector< std::pair< std::string, FrameReadingStat > > frame_reading_records_
Definition AppReport.hpp:76
void register_switch_socket_result(std::string socket_name, std::vector< std::pair< std::string, FecSwitchStat > > socket_times)
Definition AppReport.hpp:47
std::pair< std::string_view, QueueStat > queue_record_
Definition AppReport.hpp:77
void report_buffer_result()
void register_output_sink_result(std::string_view sink_name, const std::vector< std::size_t > &bytes_written)
Definition AppReport.hpp:63
std::vector< std::pair< std::string, std::vector< std::pair< std::string, FecSwitchStat > > > > switch_socket_records_
Definition AppReport.hpp:75
void report_task_result()
void register_queue_result(const QueueStat &stat)
Definition AppReport.hpp:68
void register_frame_reading_result(std::string name, const FrameReadingStat &stat)
Definition AppReport.hpp:53
std::map< std::string, std::vector< TaskStat > > task_records_
Definition AppReport.hpp:73
std::map< std::string, std::vector< std::size_t > > sink_records_
Definition AppReport.hpp:74
void report_socket_result()
void report_sink_file_result()
void report_frame_reading_result()
void register_task_result(std::string_view task_name, const std::vector< TaskStat > &process_times)
Definition AppReport.hpp:58
std::string_view connection_name
Definition AppReport.hpp:30
std::chrono::microseconds US
Definition AppReport.hpp:25
decltype(US{}.count()) USCount
Definition AppReport.hpp:26