summaryrefslogtreecommitdiffstats
path: root/player/command.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 /player/command.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 'player/command.c')
-rw-r--r--player/command.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index e1f755d46c..a41a636c7d 100644
--- a/player/command.c
+++ b/player/command.c
@@ -38,6 +38,7 @@
#include "common/codecs.h"
#include "common/msg.h"
#include "common/msg_control.h"
+#include "common/stats.h"
#include "filters/f_decoder_wrapper.h"
#include "command.h"
#include "osdep/timer.h"
@@ -2446,6 +2447,23 @@ out:
return ret;
}
+static int mp_property_perf_info(void *ctx, struct m_property *p, int action,
+ void *arg)
+{
+ MPContext *mpctx = ctx;
+
+ switch (action) {
+ case M_PROPERTY_GET_TYPE:
+ *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
+ return M_PROPERTY_OK;
+ case M_PROPERTY_GET: {
+ stats_global_query(mpctx->global, (struct mpv_node *)arg);
+ return M_PROPERTY_OK;
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg)
{
MPContext *mpctx = ctx;
@@ -3425,6 +3443,7 @@ static const struct m_property mp_properties_base[] = {
{"current-window-scale", mp_property_current_window_scale},
{"vo-configured", mp_property_vo_configured},
{"vo-passes", mp_property_vo_passes},
+ {"perf-info", mp_property_perf_info},
{"current-vo", mp_property_vo},
{"container-fps", mp_property_fps},
{"estimated-vf-fps", mp_property_vf_fps},