summaryrefslogtreecommitdiffstats
path: root/common/stats.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-04-10 00:55:39 +0200
committerwm4 <wm4@nowhere>2020-04-10 00:55:39 +0200
commita2846faa321fdfd57af01a21c2df08e5b5ffb6ca (patch)
treeb21c659aee287654d350a9e1f47f558baa0fc1ac /common/stats.c
parent437a46d443eac95ceeff174ce3d5b4bdd42f1834 (diff)
downloadmpv-a2846faa321fdfd57af01a21c2df08e5b5ffb6ca.tar.bz2
mpv-a2846faa321fdfd57af01a21c2df08e5b5ffb6ca.tar.xz
player, stats: more silly debug stuff
In addition to stats.c being gross, I don't think master branch code should be littered with debug code. But it's a helpful abomination.
Diffstat (limited to 'common/stats.c')
-rw-r--r--common/stats.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/common/stats.c b/common/stats.c
index af06457500..ce50bdc0f3 100644
--- a/common/stats.c
+++ b/common/stats.c
@@ -45,6 +45,7 @@ enum val_type {
VAL_UNSET = 0,
VAL_STATIC,
VAL_STATIC_SIZE,
+ VAL_INC,
VAL_TIME,
VAL_THREAD_CPU_TIME,
};
@@ -181,6 +182,10 @@ void stats_global_query(struct mpv_global *global, struct mpv_node *out)
talloc_free(s);
break;
}
+ case VAL_INC:
+ add_stat(out, e, NULL, e->val_d, NULL);
+ e->val_d = 0;
+ break;
case VAL_TIME: {
double t_cpu = e->val_th / 1e6;
add_stat(out, e, "cpu", t_cpu, mp_tprintf(80, "%.2f ms", t_cpu));
@@ -303,6 +308,17 @@ void stats_time_end(struct stats_ctx *ctx, const char *name)
pthread_mutex_unlock(&ctx->base->lock);
}
+void stats_event(struct stats_ctx *ctx, const char *name)
+{
+ if (!IS_ACTIVE(ctx))
+ return;
+ pthread_mutex_lock(&ctx->base->lock);
+ struct stat_entry *e = find_entry(ctx, name);
+ e->val_d += 1;
+ e->type = VAL_INC;
+ pthread_mutex_unlock(&ctx->base->lock);
+}
+
static void register_thread(struct stats_ctx *ctx, const char *name,
enum val_type type)
{