diff options
author | wm4 <wm4@nowhere> | 2020-04-09 00:27:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-04-09 00:33:38 +0200 |
commit | fd3caa264ea0848e7e30db94390063c87e247003 (patch) | |
tree | 3eb8268c1afc7a0bab5a544e4664cce23d2ab712 /video | |
parent | c5f8ec76b16268b05d1e3af8f1931eddf5165b8b (diff) | |
download | mpv-fd3caa264ea0848e7e30db94390063c87e247003.tar.bz2 mpv-fd3caa264ea0848e7e30db94390063c87e247003.tar.xz |
stats: some more performance graphs
Add an infrastructure for collecting performance-related data, use it in
some places. Add rendering of them to stats.lua.
There were two main goals: minimal impact on the normal code and normal
playback. So all these stats_* function calls either happen only during
initialization, or return immediately if no stats collection is going
on. That's why it does this lazily adding of stats entries etc. (a first
iteration made each stats entry an API thing, instead of just a single
stats_ctx, but I thought that was getting too intrusive in the "normal"
code, even if everything gets worse inside of stats.c).
You could get most of this information from various profilers (including
the extremely primitive --dump-stats thing in mpv), but this makes it
easier to see the most important information at once (at least in
theory), partially because we know best about the context of various
things.
Not very happy with this. It's all pretty primitive and dumb. At this
point I just wanted to get over with it, without necessarily having to
revisit it later, but with having my stupid statistics.
Somehow the code feels terrible. There are a lot of meh decisions in
there that could be better or worse (but mostly could be better), and it
just sucks but it's also trivial and uninteresting and does the job. I
guess I hate programming. It's so tedious and the result is always shit.
Anyway, enjoy.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/vo.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index e5f8752f07..52325ac953 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -40,6 +40,7 @@ #include "options/m_config.h" #include "common/msg.h" #include "common/global.h" +#include "common/stats.h" #include "video/hwdec.h" #include "video/mp_image.h" #include "sub/osd.h" @@ -162,6 +163,8 @@ struct vo_internal { double display_fps; double reported_display_fps; + + struct stats_ctx *stats; }; extern const struct m_sub_options gl_video_conf; @@ -294,6 +297,7 @@ static struct vo *vo_create(bool probing, struct mpv_global *global, .dispatch = mp_dispatch_create(vo), .req_frames = 1, .estimated_vsync_jitter = -1, + .stats = stats_ctx_create(vo, global, "vo"), }; mp_dispatch_set_wakeup_fn(vo->in->dispatch, dispatch_wakeup_cb, vo); pthread_mutex_init(&vo->in->lock, NULL); @@ -900,7 +904,7 @@ static bool render_frame(struct vo *vo) pthread_mutex_unlock(&in->lock); wakeup_core(vo); // core can queue new video now - MP_STATS(vo, "start video-draw"); + stats_time_start(in->stats, "video-draw"); if (vo->driver->draw_frame) { vo->driver->draw_frame(vo, frame); @@ -908,11 +912,11 @@ static bool render_frame(struct vo *vo) vo->driver->draw_image(vo, mp_image_new_ref(frame->current)); } - MP_STATS(vo, "end video-draw"); + stats_time_end(in->stats, "video-draw"); wait_until(vo, target); - MP_STATS(vo, "start video-flip"); + stats_time_start(in->stats, "video-flip"); vo->driver->flip_page(vo); @@ -927,7 +931,7 @@ static bool render_frame(struct vo *vo) if (vsync.last_queue_display_time < 0) vsync.last_queue_display_time = mp_time_us(); - MP_STATS(vo, "end video-flip"); + stats_time_end(in->stats, "video-flip"); pthread_mutex_lock(&in->lock); in->dropped_frame = prev_drop_count < vo->in->drop_count; |