]> git.sesse.net Git - nageru/blobdiff - nageru/print_latency.cpp
Make number of cards flexible at runtime.
[nageru] / nageru / print_latency.cpp
index 21098a7a5997fac8743008fe285c412566ae0e57..76f05b7ce33acc8044e88c8e007268e9820a5482 100644 (file)
@@ -14,11 +14,10 @@ using namespace std::chrono;
 
 ReceivedTimestamps find_received_timestamp(const vector<RefCountedFrame> &input_frames)
 {
-       unsigned num_cards = global_mixer->get_num_cards();
-       assert(input_frames.size() == num_cards * FRAME_HISTORY_LENGTH);
+       assert(input_frames.size() == MAX_VIDEO_CARDS * FRAME_HISTORY_LENGTH);
 
        ReceivedTimestamps ts;
-       for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+       for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
                for (unsigned frame_index = 0; frame_index < FRAME_HISTORY_LENGTH; ++frame_index) {
                        const RefCountedFrame &input_frame = input_frames[card_index * FRAME_HISTORY_LENGTH + frame_index];
                        if (input_frame == nullptr ||
@@ -34,9 +33,8 @@ ReceivedTimestamps find_received_timestamp(const vector<RefCountedFrame> &input_
 
 void LatencyHistogram::init(const string &measuring_point)
 {
-       unsigned num_cards = global_flags.num_cards;  // The mixer might not be ready yet.
-       summaries.resize(num_cards * FRAME_HISTORY_LENGTH * 2);
-       for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+       summaries.resize(MAX_VIDEO_CARDS * FRAME_HISTORY_LENGTH * 2);
+       for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
                char card_index_str[64];
                snprintf(card_index_str, sizeof(card_index_str), "%u", card_index);
                summaries[card_index].resize(FRAME_HISTORY_LENGTH);
@@ -55,7 +53,7 @@ void LatencyHistogram::init(const string &measuring_point)
                                 { "frame_age", frame_index_str },
                                 { "frame_type", "i/p" }},
                                 &summaries[card_index][frame_index][0],
-                               (frame_index == 0) ? Metrics::PRINT_ALWAYS : Metrics::PRINT_WHEN_NONEMPTY);
+                               Metrics::PRINT_WHEN_NONEMPTY);
                        global_metrics.add("latency_seconds",
                                {{ "measuring_point", measuring_point },
                                 { "card", card_index_str },
@@ -69,7 +67,7 @@ void LatencyHistogram::init(const string &measuring_point)
                                 { "frame_age", frame_index_str },
                                 { "frame_type", "total" }},
                                 &summaries[card_index][frame_index][2],
-                               (frame_index == 0) ? Metrics::PRINT_ALWAYS : Metrics::PRINT_WHEN_NONEMPTY);
+                               Metrics::PRINT_WHEN_NONEMPTY);
                }
        }
 }
@@ -91,9 +89,8 @@ void print_latency(const char *header, const ReceivedTimestamps &received_ts, bo
                        histogram->summaries[0][0][2].count_event(latency.count());
                }
        } else {
-               unsigned num_cards = global_mixer->get_num_cards();
-               assert(received_ts.ts.size() == num_cards * FRAME_HISTORY_LENGTH);
-               for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
+               assert(received_ts.ts.size() == MAX_VIDEO_CARDS * FRAME_HISTORY_LENGTH);
+               for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
                        for (unsigned frame_index = 0; frame_index < FRAME_HISTORY_LENGTH; ++frame_index) {
                                steady_clock::time_point ts = received_ts.ts[card_index * FRAME_HISTORY_LENGTH + frame_index];
                                if (ts == steady_clock::time_point::min()) {