]> git.sesse.net Git - nageru/commitdiff
Add a Futatabi metric for JPEG decode times.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 29 Feb 2020 23:07:27 +0000 (00:07 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 29 Feb 2020 23:07:27 +0000 (00:07 +0100)
futatabi/jpeg_frame_view.cpp

index eb0ed0925947b5a1571d6ba0ff46a00d1bc5385f..c95a2ce0af403d7bf99b3a052d7e7494e13d4056 100644 (file)
@@ -12,6 +12,7 @@
 #include <QMouseEvent>
 #include <QScreen>
 #include <atomic>
+#include <chrono>
 #include <condition_variable>
 #include <deque>
 #include <jpeglib.h>
@@ -29,6 +30,7 @@
 
 using namespace movit;
 using namespace std;
+using namespace std::chrono;
 
 namespace {
 
@@ -70,6 +72,7 @@ atomic<int64_t> metric_jpeg_software_decode_frames{ 0 };
 atomic<int64_t> metric_jpeg_software_fail_frames{ 0 };
 atomic<int64_t> metric_jpeg_vaapi_decode_frames{ 0 };
 atomic<int64_t> metric_jpeg_vaapi_fail_frames{ 0 };
+Summary metric_jpeg_decode_time_seconds;
 
 }  // namespace
 
@@ -82,11 +85,14 @@ extern atomic<bool> should_quit;
 
 shared_ptr<Frame> decode_jpeg(const string &jpeg)
 {
+       steady_clock::time_point start = steady_clock::now();
        shared_ptr<Frame> frame;
        if (vaapi_jpeg_decoding_usable) {
                frame = decode_jpeg_vaapi(jpeg);
                if (frame != nullptr) {
                        ++metric_jpeg_vaapi_decode_frames;
+                       steady_clock::time_point stop = steady_clock::now();
+                       metric_jpeg_decode_time_seconds.count_event(duration<double>(stop - start).count());
                        return frame;
                }
                fprintf(stderr, "VA-API hardware decoding failed; falling back to software.\n");
@@ -189,6 +195,8 @@ shared_ptr<Frame> decode_jpeg(const string &jpeg)
        }
 
        ++metric_jpeg_software_decode_frames;
+       steady_clock::time_point stop = steady_clock::now();
+       metric_jpeg_decode_time_seconds.count_event(duration<double>(stop - start).count());
        return frame;
 }
 
@@ -350,6 +358,9 @@ JPEGFrameView::JPEGFrameView(QWidget *parent)
                global_metrics.add("jpeg_decode_frames", { { "decoder", "software" }, { "result", "fail" } }, &metric_jpeg_software_fail_frames);
                global_metrics.add("jpeg_decode_frames", { { "decoder", "vaapi" }, { "result", "decode" } }, &metric_jpeg_vaapi_decode_frames);
                global_metrics.add("jpeg_decode_frames", { { "decoder", "vaapi" }, { "result", "fail" } }, &metric_jpeg_vaapi_fail_frames);
+               vector<double> quantiles{ 0.01, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99 };
+               metric_jpeg_decode_time_seconds.init(quantiles, 60.0);
+               global_metrics.add("jpeg_decode_time_seconds", &metric_jpeg_decode_time_seconds);
        });
 }