mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
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.
This commit is contained in:
11
sub/osd.c
11
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);
|
||||
|
||||
Reference in New Issue
Block a user