summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-07-01 00:31:05 +0200
committerwm4 <wm4@nowhere>2017-10-09 20:40:32 +0200
commit1691b978cf74a6429f2d99f699763008a32bd8c7 (patch)
treecdae160263fc3e1c94391eeb4526be6d0aac91f4
parent22a8b99f7aff470033109e30db54748bd47f0ead (diff)
downloadmpv-1691b978cf74a6429f2d99f699763008a32bd8c7.tar.bz2
mpv-1691b978cf74a6429f2d99f699763008a32bd8c7.tar.xz
stats: rescale graphs to make the average align with the center, if possible
For vsync measurements this is not currently done because they don't track their average
-rw-r--r--player/lua/stats.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 452907bb8f..635fa84390 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -173,9 +173,11 @@ end
-- len : The length/amount of numbers in `values`.
-- v_max : The maximum number in `values`. It is used to scale all data
-- values to a range of 0 to `v_max`.
+-- v_avg : The average number in `values`. It is used to try and center graphs
+-- if possible. May be left as nil
-- scale : A value that will be multiplied with all data values.
-- x_tics: Horizontal width multiplier for the steps
-local function generate_graph(values, i, len, v_max, scale, x_tics)
+local function generate_graph(values, i, len, v_max, v_avg, scale, x_tics)
-- Check if at least one value exists
if not values[i] then
return ""
@@ -186,6 +188,11 @@ local function generate_graph(values, i, len, v_max, scale, x_tics)
local y_max = o.font_size * 0.66
local x = 0
+ -- try and center the graph if possible, but avoid going above `scale`
+ if v_avg then
+ scale = math.min(scale, v_max / (2 * v_avg))
+ end
+
local s = {format("m 0 0 n %f %f l ", x, y_max - (y_max * values[i] / v_max * scale))}
i = ((i - 2) % len) + 1
@@ -306,7 +313,7 @@ local function append_perfdata(s, full)
if o.plot_perfdata and o.ass_formatting then
s[#s+1] = generate_graph(pass["samples"], pass["count"],
pass["count"], pass["peak"],
- 0.8, 0.25)
+ pass["avg"], 0.9, 0.25)
end
end
@@ -346,10 +353,10 @@ local function append_display_sync(s)
local ratio_graph = ""
local jitter_graph = ""
if o.plot_vsync_ratio then
- ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos, vsratio_buf.len, vsratio_buf.max, 0.8, 1)
+ ratio_graph = generate_graph(vsratio_buf, vsratio_buf.pos, vsratio_buf.len, vsratio_buf.max, nil, 0.8, 1)
end
if o.plot_vsync_jitter then
- jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos, vsjitter_buf.len, vsjitter_buf.max, 0.8, 1)
+ jitter_graph = generate_graph(vsjitter_buf, vsjitter_buf.pos, vsjitter_buf.len, vsjitter_buf.max, nil, 0.8, 1)
end
append_property(s, "vsync-ratio", {prefix="VSync Ratio:", suffix=o.prefix_sep .. ratio_graph})
append_property(s, "vsync-jitter", {prefix="VSync Jitter:", suffix=o.prefix_sep .. jitter_graph})