summaryrefslogtreecommitdiffstats
path: root/sub/osd.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-09 00:27:54 +0200
committerwm4 <wm4@nowhere>2020-04-09 00:33:38 +0200
commitfd3caa264ea0848e7e30db94390063c87e247003 (patch)
tree3eb8268c1afc7a0bab5a544e4664cce23d2ab712 /sub/osd.c
parentc5f8ec76b16268b05d1e3af8f1931eddf5165b8b (diff)
downloadmpv-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 'sub/osd.c')
-rw-r--r--sub/osd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sub/osd.c b/sub/osd.c
index e5cc677819..93e1a07162 100644
--- a/sub/osd.c
+++ b/sub/osd.c
@@ -32,6 +32,7 @@
#include "options/options.h"
#include "common/global.h"
#include "common/msg.h"
+#include "common/stats.h"
#include "player/client.h"
#include "player/command.h"
#include "osd.h"
@@ -124,6 +125,7 @@ struct osd_state *osd_create(struct mpv_global *global)
.global = global,
.log = mp_log_new(osd, global->log, "osd"),
.force_video_pts = MP_NOPTS_VALUE,
+ .stats = stats_ctx_create(osd, global, "osd"),
};
pthread_mutex_init(&osd->lock, NULL);
osd->opts = osd->opts_cache->opts;
@@ -326,11 +328,20 @@ void osd_draw(struct osd_state *osd, struct mp_osd_res res,
if (obj->sub)
sub_lock(obj->sub);
+ char *stat_type_render = obj->is_sub ? "sub-render" : "osd-render";
+ char *stat_type_draw = obj->is_sub ? "sub-draw" : "osd-draw";
+ stats_time_start(osd->stats, stat_type_render);
+
struct sub_bitmaps imgs;
render_object(osd, obj, res, video_pts, formats, &imgs);
+
+ stats_time_end(osd->stats, stat_type_render);
+
if (imgs.num_parts > 0) {
if (formats[imgs.format]) {
+ stats_time_start(osd->stats, stat_type_draw);
cb(cb_ctx, &imgs);
+ stats_time_end(osd->stats, stat_type_draw);
} else {
MP_ERR(osd, "Can't render OSD part %d (format %d).\n",
obj->type, imgs.format);